diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 2b45c64..951bd55 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -28,48 +28,16 @@ - ./tests/Drupal/Tests - ./modules/*/tests/src/Unit - ../modules/*/tests/src/Unit - ../profiles/*/tests/src/Unit - ../sites/*/modules/*/tests/src/Unit - - ./vendor - - ./drush/tests + ./tests/TestSuites/UnitTestSuite.php - ./tests/Drupal/KernelTests - ./modules/*/tests/src/Kernel - ../modules/*/tests/src/Kernel - ../profiles/*/tests/src/Kernel - ../sites/*/modules/*/tests/src/Kernel - - ./vendor - - ./drush/tests + ./tests/TestSuites/KernelTestSuite.php - ./tests/Drupal/FunctionalTests - ./modules/*/tests/src/Functional - ../modules/*/tests/src/Functional - ../profiles/*/tests/src/Functional - ../sites/*/modules/*/tests/src/Functional - - ./vendor - - ./drush/tests + ./tests/TestSuites/FunctionalTestSuite.php - ./tests/Drupal/FunctionalJavascriptTests - ./modules/*/tests/src/FunctionalJavascript - ../modules/*/tests/src/FunctionalJavascript - ../profiles/*/tests/src/FunctionalJavascript - ../sites/*/modules/*/tests/src/FunctionalJavascript - - ./vendor - - ./drush/tests + ./tests/TestSuites/FunctionalJavascriptTestSuite.php diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php index 834d0a4..7c5e855 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php @@ -22,7 +22,7 @@ /** * Base class for the actual unit tests testing \Drupal\Core\Render\Renderer. */ -class RendererTestBase extends UnitTestCase { +abstract class RendererTestBase extends UnitTestCase { /** * The tested renderer. diff --git a/core/tests/TestSuites/FunctionalJavascriptTestSuite.php b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php new file mode 100644 index 0000000..feb7b0c --- /dev/null +++ b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php @@ -0,0 +1,61 @@ +addTestFiles(static::getFunctionalJavascriptTests($root)); + return $suite; + } + + /** + * Finds the functional javascript tests. + * + * @param string $root + * Path to the root of the Drupal installation. + * + * @return string[] + * Classmap of file paths for tests, keyed by fully-qualified name. + */ + protected static function getFunctionalJavascriptTests($root = '') { + // Core's functional javascript tests are in the namespace + // Drupal\FunctionalJavascriptTests\ and are always inside of + // core/tests/Drupal/FunctionalJavascriptTests. + $classmap = TestDiscovery::scanDirectory('Drupal\\FunctionalJavascriptTests\\', $root . '/core/tests/Drupal/FunctionalJavascriptTests'); + + // Extensions' functional javascript tests will always be in the namespace + // Drupal\Tests\extension-name\FunctionalJavascript\ and be in the + // extension-path/tests/src/FunctionalJavascript directory. Not all + // extensions will have functional javascript tests. + foreach (static::findExtensionDirectories($root) as $extension_name => $dir) { + $test_path = $dir . '/tests/src/FunctionalJavascript'; + if (is_dir($test_path)) { + $classmap = array_merge( + TestDiscovery::scanDirectory("Drupal\\Tests\\$extension_name\\FunctionalJavascript\\", $test_path), + $classmap + ); + } + } + + return $classmap; + } + +} diff --git a/core/tests/TestSuites/FunctionalTestSuite.php b/core/tests/TestSuites/FunctionalTestSuite.php new file mode 100644 index 0000000..1f380e3 --- /dev/null +++ b/core/tests/TestSuites/FunctionalTestSuite.php @@ -0,0 +1,60 @@ +addTestFiles(static::getFunctionalTests($root)); + return $suite; + } + + /** + * Finds the functional tests. + * + * @param string $root + * Path to the root of the Drupal installation. + * + * @return string[] + * Classmap of file paths for tests, keyed by fully-qualified name. + */ + protected static function getFunctionalTests($root = '') { + // Core's functional tests are in the namespace Drupal\FunctionalTests\ and + // are always inside of core/tests/Drupal/FunctionalTests. + $classmap = TestDiscovery::scanDirectory('Drupal\\FunctionalTests\\', $root . '/core/tests/Drupal/FunctionalTests'); + + // Extensions' functional tests will always be in the namespace + // Drupal\Tests\extension-name\Functional\ and be in the + // extension-path/tests/src/Functional directory. Not all extensions will + // have kernel tests. + foreach (static::findExtensionDirectories() as $extension_name => $dir) { + $test_path = $dir . '/tests/src/Functional'; + if (is_dir($test_path)) { + $classmap = array_merge( + TestDiscovery::scanDirectory("Drupal\\Tests\\$extension_name\\Functional\\", $test_path), + $classmap + ); + } + } + + return $classmap; + } + +} diff --git a/core/tests/TestSuites/KernelTestSuite.php b/core/tests/TestSuites/KernelTestSuite.php new file mode 100644 index 0000000..effe555 --- /dev/null +++ b/core/tests/TestSuites/KernelTestSuite.php @@ -0,0 +1,60 @@ +addTestFiles(static::getKernelTests($root)); + return $suite; + } + + /** + * Finds the kernel tests. + * + * @param string $root + * Path to the root of the Drupal installation. + * + * @return string[] + * Classmap of file paths for tests, keyed by fully-qualified name. + */ + protected static function getKernelTests($root = '') { + // Core's kernel tests are in the namespace Drupal\KernelTests\ and are + // always inside of core/tests/Drupal/KernelTests. + $classmap = TestDiscovery::scanDirectory('Drupal\\KernelTests\\', $root . '/core/tests/Drupal/KernelTests'); + + // Extensions' kernel tests will always be in the namespace + // Drupal\Tests\extension-name\Kernel\ and be in the + // extension-path/tests/src/Kernel directory. Not all extensions will have + // kernel tests. + foreach (static::findExtensionDirectories() as $extension_name => $dir) { + $test_path = $dir . '/tests/src/Kernel'; + if (is_dir($test_path)) { + $classmap = array_merge( + TestDiscovery::scanDirectory("Drupal\\Tests\\$extension_name\\Kernel\\", $test_path), + $classmap + ); + } + } + + return $classmap; + } + +} diff --git a/core/tests/TestSuites/TestSuiteBase.php b/core/tests/TestSuites/TestSuiteBase.php new file mode 100644 index 0000000..b924010 --- /dev/null +++ b/core/tests/TestSuites/TestSuiteBase.php @@ -0,0 +1,32 @@ +addTestFiles(static::getUnitTests($root)); + return $suite; + } + + /** + * Finds the unit tests. + * + * @param string $root + * Path to the root of the Drupal installation. + * + * @return string[] + * Classmap of file paths for tests, keyed by fully-qualified name. + */ + protected static function getUnitTests($root = '') { + // Core's unit tests are in the namespace Drupal\Tests\ and are always + // inside of core/tests/Drupal/Tests. + $classmap = TestDiscovery::scanDirectory('Drupal\\Tests\\', $root . '/core/tests/Drupal/Tests'); + + // Extensions' unit tests will always be in the namespace + // Drupal\Tests\extension-name\Unit\ and be in the + // extension-path/tests/src/Unit directory. Not all extensions will have + // unit tests. + foreach (static::findExtensionDirectories() as $extension_name => $dir) { + $test_path = $dir . '/tests/src/Unit'; + if (is_dir($test_path)) { + $classmap = array_merge( + TestDiscovery::scanDirectory("Drupal\\Tests\\$extension_name\\Unit\\", $test_path), + $classmap + ); + } + } + + return $classmap; + } + +}