‪TYPO3CMS  10.4
PageTsConfigLoaderTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\Argument;
21 use Psr\EventDispatcher\EventDispatcherInterface;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
26 class ‪PageTsConfigLoaderTest extends UnitTestCase
27 {
31  public function ‪alwaysLoadDefaultSettings(): void
32  {
33  $expected = [
34  'default' => ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']
35  ];
36  $expectedString = implode('"\n[GLOBAL]\n"', $expected);
37  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
38  $subject = new ‪PageTsConfigLoader($eventDispatcher->reveal());
39  $event = new ‪ModifyLoadedPageTsConfigEvent($expected, []);
40  $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
41  $result = $subject->collect([]);
42  self::assertSame($expected, $result);
43 
44  $result = $subject->load([]);
45  self::assertSame($expectedString, $result);
46  }
47 
52  {
53  $expected = [
54  'default' => ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'],
55  'page_13' => 'waiting for = love',
56  'page_27' => '',
57  ];
58  $rootLine = [['uid' => 0, 'pid' => 0], ['uid' => 13, 'TSconfig' => 'waiting for = love'], ['uid' => 27, 'TSconfig' => '']];
59  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
60  $event = new ‪ModifyLoadedPageTsConfigEvent($expected, $rootLine);
61  $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
62  $subject = new ‪PageTsConfigLoader($eventDispatcher->reveal());
63  $result = $subject->collect($rootLine);
64  self::assertSame($expected, $result);
65  }
66 
71  {
72  $expected = [
73  'default' => ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'],
74  'page_13_includes_0' => 'Show_me = more
75 ',
76  'page_13' => 'waiting for = love',
77  'page_27' => '',
78  ];
79  $rootLine = [['uid' => 13, 'TSconfig' => 'waiting for = love', 'tsconfig_includes' => 'EXT:core/Tests/Unit/Configuration/Loader/Fixtures/included.typoscript'], ['uid' => 27, 'TSconfig' => '']];
80  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
81  $event = new ‪ModifyLoadedPageTsConfigEvent($expected, $rootLine);
82  $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
83  $subject = new ‪PageTsConfigLoader($eventDispatcher->reveal());
84  $result = $subject->collect($rootLine);
85  self::assertSame($expected, $result);
86  }
87 
91  public function ‪invalidExternalFileIsNotLoaded(): void
92  {
93  $expected = [
94  'default' => ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'],
95  'page_13' => 'waiting for = love',
96  'page_27' => '',
97  ];
98  $expectedString = implode("\n[GLOBAL]\n", $expected);
99  $rootLine = [['uid' => 13, 'TSconfig' => 'waiting for = love', 'tsconfig_includes' => 'EXT:core/Tests/Unit/Configuration/Loader/Fixtures/me_does_not_exist.typoscript'], ['uid' => 27, 'TSconfig' => '']];
100  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
101  $event = new ‪ModifyLoadedPageTsConfigEvent($expected, $rootLine);
102  $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
103  $subject = new ‪PageTsConfigLoader($eventDispatcher->reveal());
104  $result = $subject->collect($rootLine);
105  self::assertSame($expected, $result);
106 
107  $result = $subject->load($rootLine);
108  self::assertSame($expectedString, $result);
109  }
110 }
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader\PageTsConfigLoaderTest
Definition: PageTsConfigLoaderTest.php:27
‪TYPO3\CMS\Core\Configuration\Loader\PageTsConfigLoader
Definition: PageTsConfigLoader.php:39
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader\PageTsConfigLoaderTest\loadDefaultSettingsAtTheBeginningAndKeepEmptyEntriesExpectUidZero
‪loadDefaultSettingsAtTheBeginningAndKeepEmptyEntriesExpectUidZero()
Definition: PageTsConfigLoaderTest.php:51
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader
Definition: PageTsConfigLoaderTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader\PageTsConfigLoaderTest\loadExternalInclusionsCorrectlyAndKeepLoadingOrder
‪loadExternalInclusionsCorrectlyAndKeepLoadingOrder()
Definition: PageTsConfigLoaderTest.php:70
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader\PageTsConfigLoaderTest\alwaysLoadDefaultSettings
‪alwaysLoadDefaultSettings()
Definition: PageTsConfigLoaderTest.php:31
‪TYPO3\CMS\Core\Configuration\Event\ModifyLoadedPageTsConfigEvent
Definition: ModifyLoadedPageTsConfigEvent.php:24
‪TYPO3\CMS\Core\Tests\Unit\Configuration\Loader\PageTsConfigLoaderTest\invalidExternalFileIsNotLoaded
‪invalidExternalFileIsNotLoaded()
Definition: PageTsConfigLoaderTest.php:91
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5