Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The rootline calculation has been moved around with various patches in v12 & v13. Refactor some related tests and move them to a more appropriate place. This also avoids another TSFE access in tests. Resolves: #103701 Related: #102856 Related: #102715 Related: #103410 Releases: main Change-Id: I0da5f0484ce90eab3909d1c202a13ce79250b0bb Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83956 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Tested-by: Benjamin Franzke <ben@bnf.dev> Reviewed-by: Benjamin Franzke <ben@bnf.dev> Reviewed-by: Stefan Bürk <stefan@buerk.tech>
- Loading branch information
Showing
4 changed files
with
81 additions
and
199 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
typo3/sysext/frontend/Tests/Functional/Controller/Fixtures/PageHelloWorld.typoscript
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ysext/frontend/Tests/Functional/Page/DataSet/PageInformationFactoryTestRootlineImport.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"pages" | ||
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug","l10n_state" | ||
,1,0,256,0,0,0,0,0,0,0,"Pre page without template","","{}" | ||
,2,1,256,0,0,0,0,0,0,0,"Root page having template with root flag set by tests","/","{}" | ||
,88,2,256,0,0,0,0,0,0,0,"Sub page 1","/subpage1/","{}" | ||
,89,88,256,0,0,0,0,0,0,0,"Sub sub page 1","/subpage1/sub1/","{}" | ||
,98,2,256,0,0,0,0,0,0,0,"Sub page 2 having template with root flag","/subpage2/","{}" | ||
,99,98,256,0,0,0,0,0,0,0,"Sub sub page 2","/subpage2/sub2/","{}" | ||
"sys_template" | ||
,"uid","pid","sorting","deleted","hidden","starttime","endtime","root","clear","include_static_file","constants","config","basedOn","includeStaticAfterBasedOn","static_file_mode" | ||
,1,98,256,0,0,0,0,1,0,"","","","",0,0 | ||
,2,2,256,0,0,0,0,1,3,"","","","",0,0 |
69 changes: 69 additions & 0 deletions
69
typo3/sysext/frontend/Tests/Functional/Page/PageInformationFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Frontend\Tests\Functional\Page; | ||
|
||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use TYPO3\CMS\Core\Http\ServerRequest; | ||
use TYPO3\CMS\Core\Routing\PageArguments; | ||
use TYPO3\CMS\Core\Site\Entity\Site; | ||
use TYPO3\CMS\Frontend\Page\PageInformationFactory; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
final class PageInformationFactoryTest extends FunctionalTestCase | ||
{ | ||
public static function getFromCacheSetsConfigRootlineToLocalRootlineDataProvider(): \Generator | ||
{ | ||
$page1 = ['uid' => 1, 'pid' => 0, 'title' => 'Pre page without template']; | ||
$page2 = ['uid' => 2, 'pid' => 1, 'title' => 'Root page having template with root flag set by tests']; | ||
$page88 = ['uid' => 88, 'pid' => 2, 'title' => 'Sub page 1']; | ||
$page89 = ['uid' => 89, 'pid' => 88, 'title' => 'Sub sub page 1']; | ||
$page98 = ['uid' => 98, 'pid' => 2, 'title' => 'Sub page 2 having template with root flag']; | ||
$page99 = ['uid' => 99, 'pid' => 98, 'title' => 'Sub sub page 2']; | ||
yield 'page with one root template on pid 2' => [ | ||
'pid' => 89, | ||
'expectedRootLine' => [ 3 => $page89, 2 => $page88, 1 => $page2, 0 => $page1 ], | ||
'expectedLocalRootLine' => [ 0 => $page2, 1 => $page88, 2 => $page89 ], | ||
]; | ||
yield 'page with one root template on pid 2 and one on pid 98' => [ | ||
'pid' => 99, | ||
'expectedRootLine' => [ 3 => $page99, 2 => $page98, 1 => $page2, 0 => $page1 ], | ||
'expectedLocalRootLine' => [ 0 => $page98, 1 => $page99 ], | ||
]; | ||
} | ||
|
||
#[DataProvider('getFromCacheSetsConfigRootlineToLocalRootlineDataProvider')] | ||
#[Test] | ||
public function getFromCacheSetsConfigRootlineToLocalRootline(int $pid, array $expectedRootLine, array $expectedLocalRootLine): void | ||
{ | ||
$this->importCSVDataSet(__DIR__ . '/DataSet/PageInformationFactoryTestRootlineImport.csv'); | ||
$pageArguments = new PageArguments($pid, '0', []); | ||
$site = new Site('test', 2, []); | ||
$request = (new ServerRequest()) | ||
->withAttribute('routing', $pageArguments) | ||
->withAttribute('site', $site); | ||
$subject = $this->get(PageInformationFactory::class); | ||
$pageInformation = $subject->create($request); | ||
$rootLine = $pageInformation->getRootLine(); | ||
self::assertSame(array_keys($expectedRootLine), array_keys($rootLine)); | ||
self::assertArrayIsEqualToArrayOnlyConsideringListOfKeys($expectedRootLine, $rootLine, ['uid', 'pid', 'title']); | ||
$localRootLine = $pageInformation->getLocalRootLine(); | ||
self::assertSame(array_keys($expectedLocalRootLine), array_keys($localRootLine)); | ||
self::assertArrayIsEqualToArrayOnlyConsideringListOfKeys($expectedLocalRootLine, $localRootLine, ['uid', 'pid', 'title']); | ||
} | ||
} |