‪TYPO3CMS  10.4
FluidTemplateContentObjectTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
28 class ‪FluidTemplateContentObjectTest extends FunctionalTestCase
29 {
33  protected ‪$coreExtensionsToLoad = [
34  'fluid'
35  ];
36 
40  protected ‪$testExtensionsToLoad = [
41  'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
42  ];
43 
48  {
50  $tsfe = $this->createMock(TypoScriptFrontendController::class);
51  ‪$GLOBALS['TSFE'] = $tsfe;
52 
53  $configuration = [
54  '10' => 'FLUIDTEMPLATE',
55  '10.' => [
56  'template' => 'TEXT',
57  'template.' => [
58  'value' => 'A{anotherFluidTemplate}C'
59  ],
60  'variables.' => [
61  'anotherFluidTemplate' => 'FLUIDTEMPLATE',
62  'anotherFluidTemplate.' => [
63  'template' => 'TEXT',
64  'template.' => [
65  'value' => 'B',
66  ],
67  ],
68  ],
69  ],
70  ];
71  $expectedResult = 'ABC';
72 
73  $contentObjectRenderer = new ‪ContentObjectRenderer();
74  $contentObjectRenderer->setContentObjectClassMap([
75  'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
76  'TEXT' => TextContentObject::class,
77  ]);
78  $fluidTemplateContentObject = new ‪ContentObjectArrayContentObject(
79  $contentObjectRenderer
80  );
81  $result = $fluidTemplateContentObject->render($configuration);
82 
83  self::assertEquals($expectedResult, $result);
84  }
85 
90  {
92  $tsfe = $this->createMock(TypoScriptFrontendController::class);
93  ‪$GLOBALS['TSFE'] = $tsfe;
94 
95  $configuration = [
96  '10' => 'FLUIDTEMPLATE',
97  '10.' => [
98  'template' => 'TEXT',
99  'template.' => [
100  'value' => '<f:layout name="BaseLayout"/><f:section name="main"><f:format.raw>{anotherFluidTemplate}</f:format.raw></f:section>'
101  ],
102  'layoutRootPaths.' => [
103  '0' => 'EXT:fluid_test/Resources/Private/Layouts'
104  ],
105  'variables.' => [
106  'anotherFluidTemplate' => 'FLUIDTEMPLATE',
107  'anotherFluidTemplate.' => [
108  'template' => 'TEXT',
109  'template.' => [
110  'value' => '<f:layout name="BaseLayout"/><f:section name="main"></f:section>'
111  ],
112  'layoutRootPaths.' => [
113  '0' => 'EXT:fluid_test/Resources/Private/LayoutOverride/Layouts'
114  ],
115  ],
116  ],
117  ],
118  ];
119  $expectedResult = 'DefaultLayoutLayoutOverride';
120 
121  $contentObjectRenderer = new ‪ContentObjectRenderer();
122  $contentObjectRenderer->setContentObjectClassMap([
123  'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
124  'TEXT' => TextContentObject::class,
125  ]);
126  $fluidTemplateContentObject = new ‪ContentObjectArrayContentObject(
127  $contentObjectRenderer
128  );
129  $result = preg_replace('/\s+/', '', strip_tags($fluidTemplateContentObject->render($configuration)));
130 
131  self::assertEquals($expectedResult, $result);
132  }
133 }
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: FluidTemplateContentObjectTest.php:38
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\renderWorksWithNestedFluidtemplate
‪renderWorksWithNestedFluidtemplate()
Definition: FluidTemplateContentObjectTest.php:45
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\renderWorksWithNestedFluidtemplateWithLayouts
‪renderWorksWithNestedFluidtemplateWithLayouts()
Definition: FluidTemplateContentObjectTest.php:87
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest
Definition: FluidTemplateContentObjectTest.php:29
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject
Definition: ContentObjectArrayContentObject.php:25
‪TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject
Definition: FluidTemplateContentObject.php:31
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:98
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Frontend\ContentObject\TextContentObject
Definition: TextContentObject.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject
Definition: ContentObjectRendererTest.php:16
‪TYPO3\CMS\Frontend\Tests\Functional\ContentObject\FluidTemplateContentObjectTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: FluidTemplateContentObjectTest.php:32