function TestRunTest::testCreateAndRemove

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Test/TestRunTest.php \Drupal\KernelTests\Core\Test\TestRunTest::testCreateAndRemove()

@covers ::createNew @covers ::id @covers ::insertLogEntry @covers ::setDatabasePrefix

File

core/tests/Drupal/KernelTests/Core/Test/TestRunTest.php, line 89

Class

TestRunTest
@coversDefaultClass \Drupal\Core\Test\TestRun @group Test

Namespace

Drupal\KernelTests\Core\Test

Code

public function testCreateAndRemove() : void {
    $test_run_1 = TestRun::createNew($this->testRunResultsStorage);
    $test_run_1->setDatabasePrefix('oddity1234');
    $test_run_1->insertLogEntry($this->getTestLogEntry('Test\\GroundControl'));
    $this->assertEquals(1, $test_run_1->id());
    $this->assertEquals(1, $this->connection
        ->select('simpletest')
        ->countQuery()
        ->execute()
        ->fetchField());
    $this->assertEquals(1, $this->connection
        ->select('simpletest_test_id')
        ->countQuery()
        ->execute()
        ->fetchField());
    $test_run_2 = TestRun::createNew($this->testRunResultsStorage);
    $test_run_2->setDatabasePrefix('oddity5678');
    $test_run_2->insertLogEntry($this->getTestLogEntry('Test\\PlanetEarth'));
    $this->assertEquals(2, $test_run_2->id());
    $this->assertEquals(2, $this->connection
        ->select('simpletest')
        ->countQuery()
        ->execute()
        ->fetchField());
    $this->assertEquals(2, $this->connection
        ->select('simpletest_test_id')
        ->countQuery()
        ->execute()
        ->fetchField());
    $this->assertEquals(1, $test_run_1->removeResults());
    $this->assertEquals(1, $this->connection
        ->select('simpletest')
        ->countQuery()
        ->execute()
        ->fetchField());
    $this->assertEquals(1, $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.