function TestDiscoveryTest::testTestInfoParser
Same name and namespace in other branches
- 10 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testTestInfoParser()
- 9 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testTestInfoParser()
- 8.9.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::testTestInfoParser()
Tests test info parser.
@legacy-covers ::getTestInfo
Attributes
#[DataProvider('infoParserProvider')]
#[RunInSeparateProcess]
File
-
core/
tests/ Drupal/ Tests/ Core/ Test/ TestDiscoveryTest.php, line 37
Class
- TestDiscoveryTest
- Unit tests for TestDiscovery.
Namespace
Drupal\Tests\Core\TestCode
public function testTestInfoParser($expected, $classname, $doc_comment = NULL) : void {
try {
$info = TestDiscovery::getTestInfo($classname, $doc_comment);
$this->assertEquals($expected, $info);
} catch (MissingGroupException) {
// In case the test class was converted to attributes already, we need to
// get the data from PHPUnit discovery instead.
$configurationFilePath = $this->root . \DIRECTORY_SEPARATOR . 'core';
// @todo once PHPUnit 10 is no longer used, remove the condition.
// @see https://www.drupal.org/project/drupal/issues/3497116
if (RunnerVersion::getMajor() < 11) {
$configurationFilePath .= \DIRECTORY_SEPARATOR . '.phpunit-10.xml';
}
$phpUnitTestDiscovery = PhpUnitTestDiscovery::instance()->setConfigurationFilePath($configurationFilePath);
$classes = $phpUnitTestDiscovery->getTestClasses(NULL, [
$expected['type'],
]);
$info = $classes[$expected['group']][$classname];
// The 'file' and 'tests_count' keys are additional in PHPUnit, and the
// computed 'description' key may differ, but that's irrelevant. Remove
// the keys before comparison.
unset($info['file'], $info['tests_count'], $info['description'], $expected['description']);
$this->assertEquals($expected, $info);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.