Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[BUGFIX] Correctly retrieve workspace versions
* Clipboard now correctly resolves record localizations of a workspace * PageLayoutController new correctly determines sub-pages that are new in a particular workspace * SlugHelper & TypoScriptTemplateModuleController can be simplified by using WorkspaceRestriction directly * common function test scenario tree (based on YAML) is introduced for ext:backend in order to be used as structure for other tests * required testing framework changes support version and language variants and combination much better now Resolves: #89138 Releases: master Change-Id: Ia4b412d48dd3ea92adc60c729ad6feb27c22b812 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61663 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Daniel Gorges <daniel.gorges@b13.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Daniel Gorges <daniel.gorges@b13.com> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Achim Fritz <af@achimfritz.de>
- Loading branch information
Showing
12 changed files
with
497 additions
and
80 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
158 changes: 158 additions & 0 deletions
158
typo3/sysext/backend/Tests/Functional/Clipboard/ClipboardTest.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,158 @@ | ||
<?php | ||
namespace TYPO3\CMS\Backend\Tests\Functional\Clipboard; | ||
|
||
/* | ||
* 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! | ||
*/ | ||
|
||
use TYPO3\CMS\Backend\Clipboard\Clipboard; | ||
use TYPO3\CMS\Backend\Utility\BackendUtility; | ||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | ||
use TYPO3\CMS\Core\Core\Bootstrap; | ||
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory; | ||
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
/** | ||
* Functional database test for Clipboard behaviour | ||
*/ | ||
class ClipboardTest extends FunctionalTestCase | ||
{ | ||
use SiteBasedTestTrait; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
protected $coreExtensionsToLoad = ['workspaces']; | ||
|
||
/** | ||
* @var Clipboard | ||
*/ | ||
private $subject; | ||
|
||
/** | ||
* @var BackendUserAuthentication | ||
*/ | ||
private $backendUser; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
parent::setUpBeforeClass(); | ||
static::initializeDatabaseSnapshot(); | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
static::destroyDatabaseSnapshot(); | ||
parent::tearDownAfterClass(); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->subject = GeneralUtility::makeInstance(Clipboard::class); | ||
$this->backendUser = $this->setUpBackendUserFromFixture(1); | ||
|
||
$this->withDatabaseSnapshot(function () { | ||
$this->setUpDatabase(); | ||
}); | ||
} | ||
|
||
protected function setUpDatabase() | ||
{ | ||
Bootstrap::initializeLanguageObject(); | ||
|
||
$scenarioFile = __DIR__ . '/../Fixtures/CommonScenario.yaml'; | ||
$factory = DataHandlerFactory::fromYamlFile($scenarioFile); | ||
$writer = DataHandlerWriter::withBackendUser($this->backendUser); | ||
$writer->invokeFactory($factory); | ||
static::failIfArrayIsNotEmpty( | ||
$writer->getErrors() | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function localizationsAreResolvedDataProvider(): array | ||
{ | ||
return [ | ||
'live workspace with live & version localizations' => [ | ||
1100, | ||
0, | ||
[ | ||
'FR: Welcome', | ||
'FR-CA: Welcome', | ||
] | ||
], | ||
'draft workspace with live & version localizations' => [ | ||
1100, | ||
1, | ||
[ | ||
'FR: Welcome', | ||
'FR-CA: Welcome', | ||
'ES: Bienvenido', | ||
] | ||
], | ||
'live workspace with live localizations only' => [ | ||
1400, | ||
0, | ||
[ | ||
'FR: ACME in your Region', | ||
'FR-CA: ACME in your Region', | ||
] | ||
], | ||
'draft workspace with live localizations only' => [ | ||
1400, | ||
1, | ||
[ | ||
'FR: ACME in your Region', | ||
'FR-CA: ACME in your Region', | ||
] | ||
], | ||
'live workspace with version localizations only' => [ | ||
1500, | ||
0, | ||
[] | ||
], | ||
'draft workspace with version localizations only' => [ | ||
1500, | ||
1, | ||
[ | ||
'FR: Interne', | ||
] | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @param int $pageId | ||
* @param int $workspaceId | ||
* @param array $expectation | ||
* | ||
* @dataProvider localizationsAreResolvedDataProvider | ||
* @test | ||
*/ | ||
public function localizationsAreResolved(int $pageId, int $workspaceId, array $expectation) | ||
{ | ||
$this->backendUser->workspace = $workspaceId; | ||
$record = BackendUtility::getRecordWSOL('pages', $pageId); | ||
$actualResult = array_column( | ||
$this->subject->getLocalizations('pages', $record), | ||
'title' | ||
); | ||
static::assertSame($expectation, $actualResult); | ||
} | ||
} |
Oops, something went wrong.