Skip to content

Commit

Permalink
[TASK] Extract 'free mode' tests to own scenario
Browse files Browse the repository at this point in the history
To further streamline the DataHandler/DataScenarios
tests, the 'Regular' 'free mode' tests are extracted
to an own scenario setup. This avoids importing multiple
fixture files and separates the complex mix in 'Regular'.

Resolves: #103742
Related: #103734
Releases: main
Change-Id: I723c7f582910f3072fbbdcb3d7493f0eaf44e368
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84045
Tested-by: André Buchmann <andy.schliesser@gmail.com>
Reviewed-by: André Buchmann <andy.schliesser@gmail.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
lolli42 authored and maddy2101 committed Apr 27, 2024
1 parent 0e683a9 commit 270d28c
Show file tree
Hide file tree
Showing 31 changed files with 529 additions and 223 deletions.
Expand Up @@ -361,30 +361,6 @@ public function localizeContentFromNonDefaultLanguageWithAllContentElements(): v
$dataHandler->process_cmdmap();
}

/**
* Note: workspaces has an additional variant of this test "localizeContentAfterMovedInLive" that performs
* the localization of the content element after it has been moved in live first.
*
* @see localizeContentAfterMovedInLiveContent - additional workspace related variant
*/
public function localizeContentAfterMovedContent(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportFreeModeElements.csv');

// 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.
$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFreeMode, self::VALUE_PageId);
// Create new record after (relative to) previously moved one.
$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdFreeMode, ['header' => 'Testing #1']);
$this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
// Localize this new record
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newTableIds[self::TABLE_Content][0], self::VALUE_LanguageId);
$this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$newTableIds[self::TABLE_Content][0]];
}

public function createLocalizedContent(): void
{
// Run test with translations
Expand Down Expand Up @@ -610,19 +586,6 @@ public function copyPage(): void
$this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
}

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

$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][310];
$this->recordIds['newContentIdTenthLocalized'] = $newTableIds[self::TABLE_Content][311];
$this->recordIds['newContentIdTenthLocalized2'] = $newTableIds[self::TABLE_Content][312];
}

public function localizePage(): void
{
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
Expand Down
Expand Up @@ -349,30 +349,4 @@ public function createPlaceholdersAndDeleteLiveParentPage(): void
// Switch back to draft workspace
$this->setWorkspaceId(self::VALUE_WorkspaceId);
}

/**
* This is an additional workspace related scenario derived from localizeContentAfterMovedContent(), where
* the moving content element around is done in live only localizations are done in workspace.
*
* @see localizeContentAfterMovedContent
*/
public function localizeContentAfterMovedInLiveContent(): void
{
// Run test with translations
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportDefaultTranslations.csv');
$this->importCSVDataSet(__DIR__ . '/DataSet/ImportFreeModeElements.csv');

$this->setWorkspaceId(0);
// 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.
$this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFreeMode, self::VALUE_PageId);
$this->setWorkspaceId(self::VALUE_WorkspaceId);
// Create new record after (relative to) previously moved one.
$newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdFreeMode, ['header' => 'Testing #1']);
$this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
// Localize this new record
$localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newTableIds[self::TABLE_Content][0], self::VALUE_LanguageId);
$this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][$newTableIds[self::TABLE_Content][0]];
}
}

This file was deleted.

Expand Up @@ -325,13 +325,6 @@ public function localizeContentFromNonDefaultLanguageWithAllContentElements(): v
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentFromNonDefaultLanguageWithAllContentElements.csv');
}

#[Test]
public function localizeContentAfterMovedContent(): void
{
parent::localizeContentAfterMovedContent();
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedContent.csv');
}

#[Test]
public function createLocalizedContent(): void
{
Expand Down Expand Up @@ -552,24 +545,6 @@ public function copyPage(): void
->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
}

/**
* Copy page (id 90) containing content elements translated in "free mode".
* Values in l10n_source field are remapped to ids of newly copied records
* e.g. record 314 has l10n_source = 315 and record 313 has l10n_source = 314
* also note that 314 is NOT a record in the default language
*/
#[Test]
public function copyPageFreeMode(): void
{
parent::copyPageFreeMode();
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPageFreeMode.csv');

$response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
$responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
}

#[Test]
public function localizePage(): void
{
Expand Down
Expand Up @@ -136,22 +136,6 @@ public function localizeContent(): void
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContent.csv');
}

#[Test]
public function localizeContentAfterMovedContent(): void
{
parent::localizeContentAfterMovedContent();
$this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedContent.csv');
}

#[Test]
public function localizeContentAfterMovedInLiveContent(): void
{
parent::localizeContentAfterMovedInLiveContent();
$this->actionService->clearWorkspaceRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedInLiveContent.csv');
}

#[Test]
public function localizeContentFromNonDefaultLanguage(): void
{
Expand Down Expand Up @@ -332,14 +316,6 @@ public function copyPage(): void
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPage.csv');
}

#[Test]
public function copyPageFreeMode(): void
{
parent::copyPageFreeMode();
$this->actionService->clearWorkspaceRecord(self::TABLE_Page, $this->recordIds['newPageId']);
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPageFreeMode.csv');
}

#[Test]
public function localizePage(): void
{
Expand Down
Expand Up @@ -250,20 +250,6 @@ public function localizeContent(): void
->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
}

#[Test]
public function localizeContentAfterMovedContent(): void
{
parent::localizeContentAfterMovedContent();
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedContent.csv');
}

#[Test]
public function localizeContentAfterMovedInLiveContent(): void
{
parent::localizeContentAfterMovedInLiveContent();
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedInLiveContent.csv');
}

/**
* @see \TYPO3\CMS\Core\Configuration\Tca\TcaMigration::sanitizeControlSectionIntegrity()
*/
Expand Down Expand Up @@ -613,23 +599,6 @@ public function copyPage(): void
->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
}

#[Test]
public function copyPageFreeMode(): void
{
parent::copyPageFreeMode();
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPageFreeMode.csv');

$response = $this->executeFrontendSubRequest(
(new InternalRequest())->withPageId($this->recordIds['newPageId']),
(new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
);
$responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #10'));
}

#[Test]
public function localizePage(): void
{
Expand Down
Expand Up @@ -229,22 +229,6 @@ public function localizeContent(): void
->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
}

#[Test]
public function localizeContentAfterMovedContent(): void
{
parent::localizeContentAfterMovedContent();
$this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedContent.csv');
}

#[Test]
public function localizeContentAfterMovedInLiveContent(): void
{
parent::localizeContentAfterMovedInLiveContent();
$this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedInLiveContent.csv');
}

#[Test]
public function localizeContentFromNonDefaultLanguage(): void
{
Expand Down Expand Up @@ -483,26 +467,6 @@ public function copyPage(): void
->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
}

#[Test]
public function copyPageFreeMode(): void
{
parent::copyPageFreeMode();
$this->actionService->publishRecords(
[
self::TABLE_Page => [$this->recordIds['newPageId']],
self::TABLE_Content => [$this->recordIds['newContentIdTenth'], $this->recordIds['newContentIdTenthLocalized'], $this->recordIds['newContentIdTenthLocalized2']],
]
);
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPageFreeMode.csv');

$response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
$responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #10'));
}

#[Test]
public function localizePage(): void
{
Expand Down
Expand Up @@ -219,22 +219,6 @@ public function localizeContent(): void
->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
}

#[Test]
public function localizeContentAfterMovedContent(): void
{
parent::localizeContentAfterMovedContent();
$this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedContent.csv');
}

#[Test]
public function localizeContentAfterMovedInLiveContent(): void
{
parent::localizeContentAfterMovedInLiveContent();
$this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
$this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentAfterMovedInLiveContent.csv');
}

#[Test]
public function localizeContentFromNonDefaultLanguage(): void
{
Expand Down Expand Up @@ -461,21 +445,6 @@ public function copyPage(): void
->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
}

#[Test]
public function copyPageFreeMode(): void
{
parent::copyPageFreeMode();
$this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
$this->assertCSVDataSet(__DIR__ . '/DataSet/copyPageFreeMode.csv');

$response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
$responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
self::assertThat($responseSections, (new HasRecordConstraint())
->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #10'));
}

#[Test]
public function localizePage(): void
{
Expand Down

0 comments on commit 270d28c

Please sign in to comment.