2 declare(strict_types = 1);
18 use Prophecy\Argument;
25 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
55 protected function setUp()
59 $this->injectDependenciesIntoViewHelper($this->viewHelper);
61 $this->configurationManager = $this->prophesize(ConfigurationManagerInterface::class);
62 $this->contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
72 $this->setArgumentsUnderTest(
75 'typoscriptObjectPath' =>
'test',
83 $this->configurationManager->getConfiguration(Argument::any())->willReturn($configArray);
85 $this->contentObjectRenderer->start([
'foo'],
'')->willReturn();
86 $this->viewHelper->initializeArgumentsAndRender();
96 $this->viewHelper->setRenderChildrenClosure(
101 $this->setArgumentsUnderTest(
104 'typoscriptObjectPath' =>
'test',
111 $this->configurationManager->getConfiguration(Argument::any())->willReturn($configArray);
113 $this->contentObjectRenderer->start([
'foo'],
'')->willReturn();
114 $this->viewHelper->initializeArgumentsAndRender();
138 $this->contentObjectRenderer->start(Argument::cetera())->willReturn();
140 $this->setArgumentsUnderTest(
144 'typoscriptObjectPath' => $objectPath,
148 $this->expectException(\
TYPO3Fluid\Fluid\Core\ViewHelper\Exception::class);
149 $this->expectExceptionCode($exceptionCode);
150 $this->viewHelper->initializeArgumentsAndRender();
156 'value' =>
'Hello World',
164 'test.' => $subConfigArray,
168 'Single path no config' => [
180 'test.' => $subConfigArray,
185 'Multi path no config' => [
207 $this->setArgumentsUnderTest(
210 'typoscriptObjectPath' => $objectPath,
216 $this->configurationManager->getConfiguration(Argument::any())->willReturn($configArray);
218 $this->contentObjectRenderer->start([
'foo'],
'table')->willReturn();
219 $this->contentObjectRenderer->setCurrentVal(
'foo')->willReturn();
220 $this->contentObjectRenderer->cObjGetSingle(
'TEXT', $subConfigArray, Argument::any())->willReturn(
'Hello World');
222 $objectManager = $this->prophesize(ObjectManager::class);
223 $objectManager->get(ConfigurationManagerInterface::class)->willReturn($this->configurationManager->reveal());
224 GeneralUtility::addInstance(ContentObjectRenderer::class, $this->contentObjectRenderer->reveal());
225 GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
227 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
228 $expectedResult =
'Hello World';
229 $this->assertSame($expectedResult, $actualResult);
237 $this->configurationManager->getConfiguration(Argument::any())->willReturn([]);
238 $this->contentObjectRenderer->setCurrentVal(Argument::cetera())->willReturn();
239 $this->contentObjectRenderer->cObjGetSingle(Argument::cetera())->willReturn(
'');
240 $objectManager = $this->prophesize(ObjectManager::class);
241 $objectManager->get(ConfigurationManagerInterface::class)->willReturn($this->configurationManager->reveal());
242 GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
243 $GLOBALS[
'TSFE'] = $this->getAccessibleMock(TypoScriptFrontendController::class, [
'initCaches'], [],
'',
false);