Deleted branch patch1 (was 2ab5b75). HEAD is now at 42d2ce9 Issue #2742541 by klausi: ApcuBackendTest is skipped in phpunit because of wrong @requires [patch1 8be9dcb] Applying https://www.drupal.org/files/issues/2499239_95.patch 7 files changed, 278 insertions(+), 37 deletions(-) create mode 100644 core/tests/TestSuites/FunctionalJavascriptTestSuite.php create mode 100644 core/tests/TestSuites/FunctionalTestSuite.php create mode 100644 core/tests/TestSuites/KernelTestSuite.php create mode 100644 core/tests/TestSuites/TestSuiteBase.php create mode 100644 core/tests/TestSuites/UnitTestSuite.php Deleted branch patch2 (was 7d773e3). HEAD is now at 42d2ce9 Issue #2742541 by klausi: ApcuBackendTest is skipped in phpunit because of wrong @requires [patch2 9ee0ce9] Applying use_test_suite_classes-2499239-97.patch 8 files changed, 171 insertions(+), 38 deletions(-) create mode 100644 core/tests/TestSuites/FunctionalJavascriptTestSuite.php create mode 100644 core/tests/TestSuites/FunctionalTestSuite.php create mode 100644 core/tests/TestSuites/KernelTestSuite.php create mode 100644 core/tests/TestSuites/TestSuiteBase.php create mode 100644 core/tests/TestSuites/UnitTestSuite.php diff --git a/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php b/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php index f53309b..f149b7f 100644 --- a/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php +++ b/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php @@ -11,7 +11,7 @@ /** * Defines a base class for Views kernel testing. */ -class ViewsKernelTestBase extends KernelTestBase { +abstract class ViewsKernelTestBase extends KernelTestBase { use ViewResultAssertionTrait; diff --git a/core/tests/TestSuites/FunctionalJavascriptTestSuite.php b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php index feb7b0c..0a92b35 100644 --- a/core/tests/TestSuites/FunctionalJavascriptTestSuite.php +++ b/core/tests/TestSuites/FunctionalJavascriptTestSuite.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\TestSuites; -use Drupal\simpletest\TestDiscovery; -use Drupal\Tests\TestSuites\TestSuiteBase; - require_once __DIR__ . '/TestSuiteBase.php'; /** @@ -15,47 +12,16 @@ class FunctionalJavascriptTestSuite extends TestSuiteBase { /** * Factory method which loads up a suite with all functional javascript tests. * - * @return static + * @return self * The test suite. */ public static function suite() { $root = dirname(dirname(dirname(__DIR__))); $suite = new self('functional-javascript'); - $suite->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'); + $suite->addSuiteNamespace($root, 'FunctionalJavascript'); - // 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; + return $suite; } } diff --git a/core/tests/TestSuites/FunctionalTestSuite.php b/core/tests/TestSuites/FunctionalTestSuite.php index 1f380e3..cc0c3ca 100644 --- a/core/tests/TestSuites/FunctionalTestSuite.php +++ b/core/tests/TestSuites/FunctionalTestSuite.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\TestSuites; -use Drupal\simpletest\TestDiscovery; -use Drupal\Tests\TestSuites\TestSuiteBase; - require_once __DIR__ . '/TestSuiteBase.php'; /** @@ -22,39 +19,9 @@ public static function suite() { $root = dirname(dirname(dirname(__DIR__))); $suite = new self('functional'); - $suite->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'); + $suite->addSuiteNamespace($root, 'Functional'); - // 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; + return $suite; } } diff --git a/core/tests/TestSuites/KernelTestSuite.php b/core/tests/TestSuites/KernelTestSuite.php index effe555..8205ebf 100644 --- a/core/tests/TestSuites/KernelTestSuite.php +++ b/core/tests/TestSuites/KernelTestSuite.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\TestSuites; -use Drupal\simpletest\TestDiscovery; -use Drupal\Tests\TestSuites\TestSuiteBase; - require_once __DIR__ . '/TestSuiteBase.php'; /** @@ -22,39 +19,9 @@ public static function suite() { $root = dirname(dirname(dirname(__DIR__))); $suite = new self('kernel'); - $suite->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'); + $suite->addSuiteNamespace($root, 'Kernel'); - // 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; + return $suite; } } diff --git a/core/tests/TestSuites/TestSuiteBase.php b/core/tests/TestSuites/TestSuiteBase.php index b924010..ef2d84d 100644 --- a/core/tests/TestSuites/TestSuiteBase.php +++ b/core/tests/TestSuites/TestSuiteBase.php @@ -1,6 +1,7 @@ addTestFiles(TestDiscovery::scanDirectory("Drupal\\Tests\\", "$root/core/tests/Drupal/Tests")); + } + else { + $this->addTestFiles(TestDiscovery::scanDirectory("Drupal\\${suite_namespace}Tests\\", "$root/core/tests/Drupal/${suite_namespace}Tests")); + } + + // Extensions' will always be in the namespace + // Drupal\Tests\$extension_name\$suite_namespace\ and be in the + // $extension_path/tests/src/$suite_namespace directory. Not all extensions + // will have tests. + foreach (static::findExtensionDirectories() as $extension_name => $dir) { + $test_path = "$dir/tests/src/$suite_namespace"; + if (is_dir($test_path)) { + $this->addTestFiles(TestDiscovery::scanDirectory("Drupal\\Tests\\$extension_name\\$suite_namespace\\", $test_path)); + } + } + } + } diff --git a/core/tests/TestSuites/UnitTestSuite.php b/core/tests/TestSuites/UnitTestSuite.php index 23fb7df..fa8a2de 100644 --- a/core/tests/TestSuites/UnitTestSuite.php +++ b/core/tests/TestSuites/UnitTestSuite.php @@ -2,9 +2,6 @@ namespace Drupal\Tests\TestSuites; -use Drupal\simpletest\TestDiscovery; -use Drupal\Tests\TestSuites\TestSuiteBase; - require_once __DIR__ . '/TestSuiteBase.php'; /** @@ -15,46 +12,16 @@ class UnitTestSuite extends TestSuiteBase { /** * Factory method which loads up a suite with all unit tests. * - * @return static + * @return self * The test suite. */ public static function suite() { $root = dirname(dirname(dirname(__DIR__))); $suite = new self('unit'); - $suite->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'); + $suite->addSuiteNamespace($root, 'Unit'); - // 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; + return $suite; } }