function SimpletestTestRunResultsStorageTest::testBuildEnvironmentKeepingExistingResults
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Test/SimpletestTestRunResultsStorageTest.php \Drupal\KernelTests\Core\Test\SimpletestTestRunResultsStorageTest::testBuildEnvironmentKeepingExistingResults()
@covers ::buildTestingResultsEnvironment @covers ::validateTestingResultsEnvironment @covers ::createNew @covers ::insertLogEntry @covers ::cleanUp
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Test/ SimpletestTestRunResultsStorageTest.php, line 69
Class
- SimpletestTestRunResultsStorageTest
- @coversDefaultClass \Drupal\Core\Test\SimpletestTestRunResultsStorage @group Test
Namespace
Drupal\KernelTests\Core\TestCode
public function testBuildEnvironmentKeepingExistingResults() : void {
$schema = $this->connection
->schema();
// Initial build of the environment.
$this->testRunResultsStorage
->buildTestingResultsEnvironment(FALSE);
$this->assertEquals(1, $this->testRunResultsStorage
->createNew());
$test_run = TestRun::get($this->testRunResultsStorage, 1);
$this->assertEquals(1, $this->testRunResultsStorage
->insertLogEntry($test_run, $this->getTestLogEntry('Test\\GroundControl')));
$this->assertEquals(1, $this->connection
->select('simpletest')
->countQuery()
->execute()
->fetchField());
$this->assertEquals(1, $this->connection
->select('simpletest_test_id')
->countQuery()
->execute()
->fetchField());
// Build the environment again, keeping results. Results should be kept.
$this->testRunResultsStorage
->buildTestingResultsEnvironment(TRUE);
$this->assertTrue($schema->tableExists('simpletest'));
$this->assertTrue($schema->tableExists('simpletest_test_id'));
$this->assertTrue($this->testRunResultsStorage
->validateTestingResultsEnvironment());
$this->assertEquals(1, $this->connection
->select('simpletest')
->countQuery()
->execute()
->fetchField());
$this->assertEquals(1, $this->connection
->select('simpletest_test_id')
->countQuery()
->execute()
->fetchField());
$this->assertEquals(2, $this->testRunResultsStorage
->createNew());
$test_run = TestRun::get($this->testRunResultsStorage, 2);
$this->assertEquals(2, $this->testRunResultsStorage
->insertLogEntry($test_run, $this->getTestLogEntry('Test\\GroundControl')));
$this->assertEquals(2, $this->connection
->select('simpletest')
->countQuery()
->execute()
->fetchField());
$this->assertEquals(2, $this->connection
->select('simpletest_test_id')
->countQuery()
->execute()
->fetchField());
// Cleanup the environment.
$this->assertEquals(2, $this->testRunResultsStorage
->cleanUp());
$this->assertEquals(0, $this->connection
->select('simpletest')
->countQuery()
->execute()
->fetchField());
$this->assertEquals(0, $this->connection
->select('simpletest_test_id')
->countQuery()
->execute()
->fetchField());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.