class PhpUnitApiFindAllClassFilesTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Test/PhpUnitApiFindAllClassFilesTest.php \Drupal\KernelTests\Core\Test\PhpUnitApiFindAllClassFilesTest
Tests ::findAllClassFiles() between TestDiscovery and PhpUnitTestDiscovery.
PhpUnitTestDiscovery uses PHPUnit API to build the list of test classes, while TestDiscovery uses Drupal legacy code.
Attributes
#[CoversClass(PhpUnitTestDiscovery::class)]
#[Group('TestSuites')]
#[Group('Test')]
#[Group('#slow')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Test\PhpUnitApiFindAllClassFilesTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of PhpUnitApiFindAllClassFilesTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Test/ PhpUnitApiFindAllClassFilesTest.php, line 22
Namespace
Drupal\KernelTests\Core\TestView source
class PhpUnitApiFindAllClassFilesTest extends KernelTestBase {
/**
* Checks that Drupal legacy and PHPUnit API based discoveries are equal.
*/
public function testEquality(?string $extension = NULL, ?string $directory = NULL) : void {
// PHPUnit discovery.
$configurationFilePath = $this->container
->getParameter('app.root') . \DIRECTORY_SEPARATOR . 'core';
$phpUnitTestDiscovery = PhpUnitTestDiscovery::instance()->setConfigurationFilePath($configurationFilePath);
$phpUnitList = $phpUnitTestDiscovery->findAllClassFiles($extension, $directory);
// Legacy TestDiscovery.
$testDiscovery = new TestDiscovery($this->container
->getParameter('app.root'), $this->container
->get('class_loader'));
$internalList = $testDiscovery->findAllClassFiles($extension, $directory);
// Downgrade results to make them comparable, working around bugs and
// additions.
// 1. TestDiscovery discovers non-test classes that PHPUnit does not.
$internalList = array_intersect_key($internalList, $phpUnitList);
$this->assertEquals($internalList, $phpUnitList);
}
/**
* Provides test data to ::testEquality.
*/
public static function argumentsProvider() : \Generator {
yield 'All tests' => [];
yield 'Extension: system' => [
'extension' => 'system',
];
yield 'Extension: system, directory' => [
'extension' => 'system',
'directory' => 'core/modules/system/tests/src',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.