‪TYPO3CMS  ‪main
PageTsConfigFactoryPageLayoutConditionTest.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 PHPUnit\Framework\Attributes\Test;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
30 final class ‪PageTsConfigFactoryPageLayoutConditionTest extends FunctionalTestCase
31 {
33 
34  protected const ‪LANGUAGE_PRESETS = [
35  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
36  ];
37 
38  public function ‪setUp(): void
39  {
40  parent::setUp();
42  'tree_page_layout_test',
43  $this->‪buildSiteConfiguration(1, '/'),
44  );
45  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
46  $this->setUpBackendUser(1);
47  }
48 
49  #[Test]
51  {
52  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutOnRootPage.csv');
53  $fullRootLine = BackendUtility::BEgetRootLine(1, '', true);
54  ksort($fullRootLine);
55  $subject = $this->get(PageTsConfigFactory::class);
56  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
57  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
58  self::assertStringContainsString('Default Layout', $pageTsConfigArray['layout'] ?? '');
59  }
60 
61  #[Test]
63  {
64  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutNextLevelOnRootPage.csv');
65  $fullRootLine = BackendUtility::BEgetRootLine(1, '', true);
66  ksort($fullRootLine);
67  $subject = $this->get(PageTsConfigFactory::class);
68  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
69  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
70  self::assertStringNotContainsString('Default Layout', $pageTsConfigArray['layout'] ?? '');
71  }
72 
73  #[Test]
75  {
76  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutAndNextLevelOnRootPage.csv');
77  $fullRootLine = BackendUtility::BEgetRootLine(2, '', true);
78  ksort($fullRootLine);
79  $subject = $this->get(PageTsConfigFactory::class);
80  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
81  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
82  self::assertStringContainsString('Inherited Layout', $pageTsConfigArray['layout'] ?? '');
83  }
84 
85  #[Test]
87  {
88  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutAndNextLevelOnRootPageSubOverride1.csv');
89  $fullRootLine = BackendUtility::BEgetRootLine(3, '', true);
90  ksort($fullRootLine);
91  $subject = $this->get(PageTsConfigFactory::class);
92  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
93  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
94  self::assertStringContainsString('Inherited Layout', $pageTsConfigArray['layout'] ?? '');
95  }
96 
97  #[Test]
99  {
100  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutAndNextLevelOnRootPageSubOverride2.csv');
101  $fullRootLine = BackendUtility::BEgetRootLine(4, '', true);
102  ksort($fullRootLine);
103  $subject = $this->get(PageTsConfigFactory::class);
104  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
105  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
106  self::assertStringContainsString('Extra Layout', $pageTsConfigArray['layout'] ?? '');
107  }
108 
109  #[Test]
111  {
112  $this->importCSVDataSet(__DIR__ . '/Fixtures/PageTsConfigFactoryPageLayoutCondition/backendLayoutAndNextLevelOnRootPageSubOverride3.csv');
113  $fullRootLine = BackendUtility::BEgetRootLine(4, '', true);
114  ksort($fullRootLine);
115  $subject = $this->get(PageTsConfigFactory::class);
116  $pageTsConfig = $subject->create($fullRootLine, new ‪NullSite());
117  $pageTsConfigArray = $pageTsConfig->getPageTsConfigArray();
118  self::assertStringContainsString('Extra Layout', $pageTsConfigArray['layout'] ?? '');
119  }
120 }
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\setUp
‪setUp()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionMetForBackendLayoutOnRootPage
‪treePageLayoutConditionMetForBackendLayoutOnRootPage()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:49
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionMetForBackendLayoutOnSubpageLevel3
‪treePageLayoutConditionMetForBackendLayoutOnSubpageLevel3()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:97
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Core\Site\Entity\NullSite
Definition: NullSite.php:32
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionMetForBackendLayoutNextLevelInheritedOnSubpageLevel1
‪treePageLayoutConditionMetForBackendLayoutNextLevelInheritedOnSubpageLevel1()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:73
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionMetForBackendLayoutNextLevelInheritedOnSubpageLevel2
‪treePageLayoutConditionMetForBackendLayoutNextLevelInheritedOnSubpageLevel2()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:85
‪TYPO3\CMS\Core\TypoScript\PageTsConfigFactory
Definition: PageTsConfigFactory.php:44
‪TYPO3\CMS\Core\Tests\Functional\TypoScript
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionNotMetForBackendLayoutNextLevelOnRootPage
‪treePageLayoutConditionNotMetForBackendLayoutNextLevelOnRootPage()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:61
‪TYPO3\CMS\Core\Tests\Functional\TypoScript\PageTsConfigFactoryPageLayoutConditionTest\treePageLayoutConditionMetForBackendLayoutNextLevelOverrideOnSubpageLevel3
‪treePageLayoutConditionMetForBackendLayoutNextLevelOverrideOnSubpageLevel3()
Definition: PageTsConfigFactoryPageLayoutConditionTest.php:109