function TestDiscoveryTest::testGetTestsInProfiles

Same name in this branch
  1. 8.9.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestsInProfiles()
Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestsInProfiles()
  2. 10 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestsInProfiles()
  3. 11.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testGetTestsInProfiles()

@covers ::getTestClasses

File

core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php, line 204

Class

TestDiscoveryTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21simpletest%21src%21TestDiscovery.php/class/TestDiscovery/8.9.x" title="Discovers available tests." class="local">\Drupal\simpletest\TestDiscovery</a>

Namespace

Drupal\Tests\simpletest\Unit

Code

public function testGetTestsInProfiles() {
    $this->setupVfsWithTestClasses();
    $class_loader = $this->prophesize(ClassLoader::class);
    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $container = new Container();
    $container->set('kernel', new DrupalKernel('prod', new ClassLoader()));
    $container->set('site.path', 'sites/default');
    \Drupal::setContainer($container);
    $test_discovery = new TestDiscovery('vfs://drupal', $class_loader->reveal(), $module_handler->reveal());
    $result = $test_discovery->getTestClasses('test_profile_module', [
        'PHPUnit-Kernel',
    ]);
    $expected = [
        'example3' => [
            'Drupal\\Tests\\test_profile_module\\Kernel\\KernelExampleTest4' => [
                'name' => 'Drupal\\Tests\\test_profile_module\\Kernel\\KernelExampleTest4',
                'description' => 'Test description',
                'group' => 'example3',
                'groups' => [
                    'example3',
                ],
                'type' => 'PHPUnit-Kernel',
            ],
        ],
    ];
    $this->assertEquals($expected, $result);
}

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