function TestRunTest::testGetLogEntriesByTestClass

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

@covers ::createNew @covers ::insertLogEntry @covers ::setDatabasePrefix @covers ::getLogEntriesByTestClass @covers ::getDatabasePrefix @covers ::getTestClass

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Test

Code

public function testGetLogEntriesByTestClass() : void {
    $test_run = TestRun::createNew($this->testRunResultsStorage);
    $test_run->setDatabasePrefix('oddity1234');
    $this->assertEquals(1, $test_run->insertLogEntry($this->getTestLogEntry('Test\\PlanetEarth')));
    $this->assertEquals(2, $test_run->insertLogEntry($this->getTestLogEntry('Test\\GroundControl')));
    $this->assertEquals([
        0 => (object) [
            'message_id' => 2,
            'test_id' => 1,
            'test_class' => 'Test\\GroundControl',
            'status' => 'pass',
            'message' => 'Major Tom',
            'message_group' => 'other',
            'function' => 'Unknown',
            'line' => 0,
            'file' => 'Unknown',
        ],
        1 => (object) [
            'message_id' => 1,
            'test_id' => 1,
            'test_class' => 'Test\\PlanetEarth',
            'status' => 'pass',
            'message' => 'Major Tom',
            'message_group' => 'other',
            'function' => 'Unknown',
            'line' => 0,
            'file' => 'Unknown',
        ],
    ], $test_run->getLogEntriesByTestClass());
    $this->assertEquals('oddity1234', $test_run->getDatabasePrefix());
    $this->assertEquals('Test\\GroundControl', $test_run->getTestClass());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.