‪TYPO3CMS  9.5
FluidTemplateContentObjectTest.php
Go to the documentation of this file.
1 <?php
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  */
18 
22 class ‪FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
23 {
27  protected ‪$coreExtensionsToLoad = [
28  'fluid'
29  ];
30 
34  protected ‪$testExtensionsToLoad = [
35  'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
36  ];
37 
42  {
44  $tsfe = $this->createMock(\‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
45  ‪$GLOBALS['TSFE'] = $tsfe;
46 
47  $configuration = [
48  '10' => 'FLUIDTEMPLATE',
49  '10.' => [
50  'template' => 'TEXT',
51  'template.' => [
52  'value' => 'A{anotherFluidTemplate}C'
53  ],
54  'variables.' => [
55  'anotherFluidTemplate' => 'FLUIDTEMPLATE',
56  'anotherFluidTemplate.' => [
57  'template' => 'TEXT',
58  'template.' => [
59  'value' => 'B',
60  ],
61  ],
62  ],
63  ],
64  ];
65  $expectedResult = 'ABC';
66 
67  $contentObjectRenderer = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
68  $contentObjectRenderer->setContentObjectClassMap([
69  'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
70  'TEXT' => TextContentObject::class,
71  ]);
72  $fluidTemplateContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject(
73  $contentObjectRenderer
74  );
75  $result = $fluidTemplateContentObject->render($configuration);
76 
77  $this->assertEquals($expectedResult, $result);
78  }
79 
84  {
86  $tsfe = $this->createMock(\‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
87  ‪$GLOBALS['TSFE'] = $tsfe;
88 
89  $configuration = [
90  '10' => 'FLUIDTEMPLATE',
91  '10.' => [
92  'template' => 'TEXT',
93  'template.' => [
94  'value' => '<f:layout name="BaseLayout"/><f:section name="main"><f:format.raw>{anotherFluidTemplate}</f:format.raw></f:section>'
95  ],
96  'layoutRootPaths.' => [
97  '0' => 'EXT:fluid_test/Resources/Private/Layouts'
98  ],
99  'variables.' => [
100  'anotherFluidTemplate' => 'FLUIDTEMPLATE',
101  'anotherFluidTemplate.' => [
102  'template' => 'TEXT',
103  'template.' => [
104  'value' => '<f:layout name="BaseLayout"/><f:section name="main"></f:section>'
105  ],
106  'layoutRootPaths.' => [
107  '0' => 'EXT:fluid_test/Resources/Private/LayoutOverride/Layouts'
108  ],
109  ],
110  ],
111  ],
112  ];
113  $expectedResult = 'DefaultLayoutLayoutOverride';
114 
115  $contentObjectRenderer = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
116  $contentObjectRenderer->setContentObjectClassMap([
117  'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
118  'TEXT' => TextContentObject::class,
119  ]);
120  $fluidTemplateContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject(
121  $contentObjectRenderer
122  );
123  $result = preg_replace('/\s+/', '', strip_tags($fluidTemplateContentObject->render($configuration)));
124 
125  $this->assertEquals($expectedResult, $result);
126  }
127 }
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: FluidTemplateContentObjectTest.php:32
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\renderWorksWithNestedFluidtemplate
‪renderWorksWithNestedFluidtemplate()
Definition: FluidTemplateContentObjectTest.php:39
‪TYPO3
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\renderWorksWithNestedFluidtemplateWithLayouts
‪renderWorksWithNestedFluidtemplateWithLayouts()
Definition: FluidTemplateContentObjectTest.php:81
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest
Definition: FluidTemplateContentObjectTest.php:23
‪TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject
Definition: FluidTemplateContentObject.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\ContentObject\TextContentObject
Definition: TextContentObject.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject
Definition: ContentObjectRendererTest.php:2
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: FluidTemplateContentObjectTest.php:26