Skip to content

Commit

Permalink
[TASK] Speed up a functional test using snapshot
Browse files Browse the repository at this point in the history
Using functional test related .yaml scenario setup
which uses DataHandler to prime the test database
is pretty slow.
TreeControllerTest can speed up using the
withDatabaseSnapshot() method to cache db results
for subsequent tests.

Resolves: #97934
Releases: main
Change-Id: I4c8f40f181f77bf07a0b26825138cb1577fe441e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75173
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
lolli42 committed Jul 14, 2022
1 parent 559269c commit 6817177
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ protected function setUp(): void
//admin user for importing dataset
$this->backendUser = $this->setUpBackendUser(1);

$this->setUpDatabase();
$this->withDatabaseSnapshot(function () {
Bootstrap::initializeLanguageObject();
$scenarioFile = __DIR__ . '/Fixtures/PagesWithBEPermissions.yaml';
$factory = DataHandlerFactory::fromYamlFile($scenarioFile);
$writer = DataHandlerWriter::withBackendUser($this->backendUser);
$writer->invokeFactory($factory);
static::failIfArrayIsNotEmpty($writer->getErrors());
});

//regular editor, non admin
$this->backendUser = $this->setUpBackendUser(9);
Expand All @@ -73,18 +80,6 @@ protected function tearDown(): void
parent::tearDown();
}

protected function setUpDatabase(): void
{
Bootstrap::initializeLanguageObject();
$scenarioFile = __DIR__ . '/Fixtures/PagesWithBEPermissions.yaml';
$factory = DataHandlerFactory::fromYamlFile($scenarioFile);
$writer = DataHandlerWriter::withBackendUser($this->backendUser);
$writer->invokeFactory($factory);
static::failIfArrayIsNotEmpty(
$writer->getErrors()
);
}

/**
* @test
*/
Expand Down

0 comments on commit 6817177

Please sign in to comment.