Skip to content

Commit

Permalink
[TASK] Create valid source data for DataHandler tests
Browse files Browse the repository at this point in the history
Tests in DataScenarios/Regular for the DataHandler are based on invalid
source data. There are translated content elements on pages that have
no translations. It's not possible to translate content elements without
having a page translation first in the backend. A lot of the tests use
workarounds and create those missing page translations first.

The tests should be based on valid source data in order to check the
pages and handling of the content.

There is now a dedicated csv file containing tt_content and their
related pages records to run tests with translations. For this reason,
all tests that do not include a page translation process themselves
import the default translations via a separate csv file. Accordingly,
the tests localizePage*, localizeAndCopyPage*, localizeNestedPages* and
movePageLocalized* do not import the default translations.

It is also ensured that no content translation exist in the source data
without a corresponding page translation.

Resolves: #103734
Releases: main
Change-Id: I9475c8e4fee53b1925a0d8bc4f33acd58dd29aa4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83632
Tested-by: Eric Harrer <info@eric-harrer.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Eric Harrer <info@eric-harrer.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
  • Loading branch information
schliesser authored and lolli42 committed Apr 26, 2024
1 parent 2f23b3e commit eef9e63
Show file tree
Hide file tree
Showing 307 changed files with 2,686 additions and 2,773 deletions.

Large diffs are not rendered by default.

Expand Up @@ -22,10 +22,6 @@ abstract class AbstractActionWorkspacesTestCase extends AbstractActionTestCase
protected const VALUE_ParentPageId = 88;
protected const VALUE_ContentIdZero = 296;

protected const VALUE_ContentIdTenth = 310;
protected const VALUE_ContentIdTenthLocalized = 311;
protected const VALUE_ContentIdTenthLocalized2 = 312;

protected const VALUE_WorkspaceId = 1;

protected const SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefaultWorkspaces.csv';
Expand All @@ -34,6 +30,9 @@ abstract class AbstractActionWorkspacesTestCase extends AbstractActionTestCase

public function createContentAndCopyContent(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
$this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
$copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
Expand All @@ -43,8 +42,9 @@ public function createContentAndCopyContent(): void

public function createContentAndLocalize(): void
{
// Create translated page first
$this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
$this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
$localizedContentId = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_LanguageId);
Expand All @@ -53,12 +53,18 @@ public function createContentAndLocalize(): void

public function changeContentSortingAndDeleteMovedRecord(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
}

public function changeContentSortingAndDeleteLiveRecord(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
// Switch to live workspace
$this->setWorkspaceId(0);
Expand All @@ -69,25 +75,22 @@ public function changeContentSortingAndDeleteLiveRecord(): void

public function deleteContentAndPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
$this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
}

public function copyPageFreeMode(): void
{
$newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdTarget);
$this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageIdTarget];
$this->recordIds['newContentIdTenth'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenth];
$this->recordIds['newContentIdTenthLocalized'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized];
$this->recordIds['newContentIdTenthLocalized2'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdTenthLocalized2];
}

/**
* @see https://forge.typo3.org/issues/33104
* @see https://forge.typo3.org/issues/55573
*/
public function movePageToDifferentPageAndCreatePageAfterMovedPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
$newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, ['title' => 'Testing #1', 'hidden' => 0]);
$this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
Expand All @@ -98,6 +101,9 @@ public function movePageToDifferentPageAndCreatePageAfterMovedPage(): void
*/
public function createContentAndCopyDraftPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
$this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
$newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
Expand All @@ -109,6 +115,9 @@ public function createContentAndCopyDraftPage(): void
*/
public function createContentAndCopyLivePage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1']);
$this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];

Expand All @@ -127,6 +136,9 @@ public function createContentAndCopyLivePage(): void
*/
public function createPageAndCopyDraftParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->backendUser->uc['copyLevels'] = 10;

$newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
Expand All @@ -140,6 +152,9 @@ public function createPageAndCopyDraftParentPage(): void
*/
public function createPageAndCopyLiveParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->backendUser->uc['copyLevels'] = 10;

$newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
Expand All @@ -160,6 +175,9 @@ public function createPageAndCopyLiveParentPage(): void
*/
public function createNestedPagesAndCopyDraftParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->backendUser->uc['copyLevels'] = 10;

$newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
Expand All @@ -177,6 +195,9 @@ public function createNestedPagesAndCopyDraftParentPage(): void
*/
public function createNestedPagesAndCopyLiveParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->backendUser->uc['copyLevels'] = 10;

$newTableIds = $this->actionService->createNewRecord(static::TABLE_Page, static::VALUE_PageId, ['title' => 'Testing #1', 'hidden' => 0]);
Expand All @@ -199,6 +220,9 @@ public function createNestedPagesAndCopyLiveParentPage(): void
*/
public function deleteContentAndCopyDraftPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
$newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
$this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
Expand All @@ -209,6 +233,9 @@ public function deleteContentAndCopyDraftPage(): void
*/
public function deleteContentAndCopyLivePage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);

// Switch to live workspace
Expand All @@ -226,6 +253,9 @@ public function deleteContentAndCopyLivePage(): void
*/
public function changeContentSortingAndCopyDraftPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
$newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
$this->recordIds['copiedPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
Expand All @@ -236,6 +266,9 @@ public function changeContentSortingAndCopyDraftPage(): void
*/
public function changeContentSortingAndCopyLivePage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);

// Switch to live workspace
Expand All @@ -253,6 +286,9 @@ public function changeContentSortingAndCopyLivePage(): void
*/
public function moveContentAndCopyDraftPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);
$newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
Expand All @@ -264,6 +300,9 @@ public function moveContentAndCopyDraftPage(): void
*/
public function moveContentAndCopyLivePage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdZero, self::VALUE_PageId);

Expand All @@ -282,6 +321,9 @@ public function moveContentAndCopyLivePage(): void
*/
public function createPlaceholdersAndDeleteDraftParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
$this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);
$newTableIds = $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_ParentPageId);
Expand All @@ -293,6 +335,9 @@ public function createPlaceholdersAndDeleteDraftParentPage(): void
*/
public function createPlaceholdersAndDeleteLiveParentPage(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');

$this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
$this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_ParentPageId, ['title' => 'Testing #1']);

Expand All @@ -313,9 +358,11 @@ public function createPlaceholdersAndDeleteLiveParentPage(): void
*/
public function localizeContentAfterMovedInLiveContent(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportFreeModeElements.csv');

$this->setWorkspaceId(0);
// Create translated page first
$this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
// Default language element 310 on page 90 that has two 'free mode' localizations is moved to page 89.
// Note the two localizations are NOT moved along with the default language element, due to free mode.
// Note l10n_source of first localization 311 is kept and still points to 310, even though 310 is moved to different page.
Expand Down
Expand Up @@ -13,11 +13,3 @@
,297,89,384,0,0,0,0,0,0,0,0,"Regular Element #1",
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",
,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3",
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",
"sys_refindex",,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",,
,"1130084e4038e95f2d5806b731cd416a","tt_content",300,"l18n_parent",,,,0,0,"tt_content",299,,,
,"4a1e04a83a4a17882682d86f6cd61f3d","tt_content",301,"l18n_parent",,,,0,0,"tt_content",297,,,
,"25f3b71b67f29fa33fbfd4fa2d930b70","tt_content",302,"l18n_parent",,,,0,0,"tt_content",297,,,
@@ -0,0 +1,16 @@
"pages",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug"
,91,88,256,0,1,89,89,0,0,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations"
,92,88,256,0,2,89,89,0,0,0,0,"[Translate to Deutsch:] Relations","/data-handler/translate-to-deutsch-relations"
"tt_content",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","bodytext"
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",
"sys_refindex",,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",
,"1130084e4038e95f2d5806b731cd416a","tt_content",300,"l18n_parent",,,,0,0,"tt_content",299,,
,"4a1e04a83a4a17882682d86f6cd61f3d","tt_content",301,"l18n_parent",,,,0,0,"tt_content",297,,
,"25f3b71b67f29fa33fbfd4fa2d930b70","tt_content",302,"l18n_parent",,,,0,0,"tt_content",297,,
,"583b9974d1df1d9efb695cdabfe53a73","pages",91,"l10n_parent",,,,0,0,"pages",89,,
,"2a42323931078b2842779bd9446e8152","pages",92,"l10n_parent",,,,0,0,"pages",89,,
Expand Up @@ -17,17 +17,8 @@
,297,89,384,0,0,0,0,0,0,0,0,0,"Regular Element #1",,,
,298,89,512,0,0,0,0,0,0,0,0,0,"Regular Element #2",,,
,299,89,768,0,0,0,0,0,0,0,0,0,"Regular Element #3",,,
,300,89,1024,0,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",,,
,301,89,384,0,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",,,
,302,89,448,0,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",,,
,310,90,256,0,0,0,0,0,0,0,0,0,"Regular Element #10",,,
,311,90,512,0,0,1,0,310,0,0,0,0,"[Translate to Dansk:] Regular Element #10",,,
,312,90,768,0,0,2,0,311,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #10",,,
,320,89,512,0,0,0,0,0,2,2,0,298,"Regular Element #2",,,
"sys_refindex",,,,,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",,,,,
,"1130084e4038e95f2d5806b731cd416a","tt_content",300,"l18n_parent",,,,0,0,"tt_content",299,,,,,,
,"4a1e04a83a4a17882682d86f6cd61f3d","tt_content",301,"l18n_parent",,,,0,0,"tt_content",297,,,,,,
,"25f3b71b67f29fa33fbfd4fa2d930b70","tt_content",302,"l18n_parent",,,,0,0,"tt_content",297,,,,,,
,"25426f92d44dd2ccf416108462b446e3","sys_workspace",1,"custom_stages",,,,0,0,"sys_workspace_stage",1,,,,,,
,"01a3ce8c4e3b2bb1aa439dc29081f996","sys_workspace_stage",1,"responsible_persons",,,,0,0,"be_users",3,,,,,,
@@ -1,5 +1,13 @@
"pages",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug"
,100,88,256,0,1,90,90,0,0,0,0,"[Translate to Dansk:] Target","/data-handler/translate-to-dansk-target"
,101,88,256,0,2,90,90,0,0,0,0,"[Translate to Deutsch:] Target","/data-handler/translate-to-deutsch-target"
"tt_content",,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header"
,310,90,256,0,0,0,0,0,0,0,0,"Regular Element #10"
,311,90,512,0,1,0,310,0,0,0,0,"[Translate to Dansk:] Regular Element #10"
,312,90,768,0,2,0,311,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #10"
"sys_refindex",,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",
,"811c1b9b63612efde79cdcdc83dbbb7a","pages",100,"l10n_parent",,,,0,0,"pages",90,,
,"1eeeb475499458a4b827f36672c0b398","pages",101,"l10n_parent",,,,0,0,"pages",90,,

0 comments on commit eef9e63

Please sign in to comment.