function TestDiscoveryTest::testGetTestClasses

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestClasses()
  2. 8.9.x core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php \Drupal\Tests\simpletest\Unit\TestDiscoveryTest::testGetTestClasses()
  3. 8.9.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestClasses()
  4. 11.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestClasses()

@covers ::getTestClasses

File

core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php, line 302

Class

TestDiscoveryTest
@coversDefaultClass \Drupal\Core\Test\TestDiscovery @group Test

Namespace

Drupal\Tests\Core\Test

Code

public function testGetTestClasses() : void {
    $this->setupVfsWithTestClasses();
    $extensions = [
        'test_module' => new Extension('vfs://drupal', 'module', 'modules/test_module/test_module.info.yml'),
    ];
    $test_discovery = $this->getTestDiscoveryMock('vfs://drupal', $extensions);
    $result = $test_discovery->getTestClasses();
    $this->assertCount(3, $result);
    $this->assertEquals([
        'example' => [
            'Drupal\\Tests\\test_module\\Functional\\FunctionalExampleTest' => [
                'name' => 'Drupal\\Tests\\test_module\\Functional\\FunctionalExampleTest',
                'description' => 'Test description',
                'group' => 'example',
                'groups' => [
                    'example',
                ],
                'type' => 'PHPUnit-Functional',
            ],
        ],
        'example2' => [
            'Drupal\\Tests\\test_module\\Functional\\FunctionalExampleTest2' => [
                'name' => 'Drupal\\Tests\\test_module\\Functional\\FunctionalExampleTest2',
                'description' => 'Test description',
                'group' => 'example2',
                'groups' => [
                    'example2',
                ],
                'type' => 'PHPUnit-Functional',
            ],
            'Drupal\\Tests\\test_module\\Kernel\\KernelExampleTest3' => [
                'name' => 'Drupal\\Tests\\test_module\\Kernel\\KernelExampleTest3',
                'description' => 'Test description',
                'group' => 'example2',
                'groups' => [
                    'example2',
                    'kernel',
                ],
                'type' => 'PHPUnit-Kernel',
            ],
        ],
        'kernel' => [
            'Drupal\\Tests\\test_module\\Kernel\\KernelExampleTest3' => [
                'name' => 'Drupal\\Tests\\test_module\\Kernel\\KernelExampleTest3',
                'description' => 'Test description',
                'group' => 'example2',
                'groups' => [
                    'example2',
                    'kernel',
                ],
                'type' => 'PHPUnit-Kernel',
            ],
        ],
    ], $result);
}

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