01d83a88aa150cd950af7c2c5918a09b9d97778d
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / ContentObject / FluidTemplateContentObjectTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Functional\ContentObject;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject;
17 use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
18
19 /**
20 * Test case
21 */
22 class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
23 {
24 protected $coreExtensionsToLoad = ['fluid'];
25
26 /**
27 * @test
28 */
29 public function renderWorksWithNestedFluidtemplate()
30 {
31 /** @var $tsfe \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
32 $tsfe = $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
33 $GLOBALS['TSFE'] = $tsfe;
34
35 $configuration = [
36 '10' => 'FLUIDTEMPLATE',
37 '10.' => [
38 'template' => 'TEXT',
39 'template.' => [
40 'value' => 'A{anotherFluidTemplate}C'
41 ],
42 'variables.' => [
43 'anotherFluidTemplate' => 'FLUIDTEMPLATE',
44 'anotherFluidTemplate.' => [
45 'template' => 'TEXT',
46 'template.' => [
47 'value' => 'B',
48 ],
49 ],
50 ],
51 ],
52 ];
53 $expectedResult = 'ABC';
54
55 $contentObjectRenderer = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
56 $contentObjectRenderer->setContentObjectClassMap([
57 'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
58 'TEXT' => TextContentObject::class,
59 ]);
60 $fluidTemplateContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject(
61 $contentObjectRenderer
62 );
63 $result = $fluidTemplateContentObject->render($configuration);
64
65 $this->assertEquals($expectedResult, $result);
66 }
67 }