diff --git a/src/TestSuite/Base.php b/src/TestSuite/Base.php deleted file mode 100644 index a4e4176aa10d5245955bf9613d09f6fc0421eefc..0000000000000000000000000000000000000000 --- a/src/TestSuite/Base.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace LakeDrops\DrupalDevelopmentEnvironment\TestSuite; - -require_once 'web/core/tests/TestSuites/TestSuiteBase.php'; - -use Drupal\Core\Test\TestDiscovery; -use Drupal\Tests\TestSuites\TestSuiteBase; - -/** - * Base class for Drupal test suites. - */ -abstract class Base extends TestSuiteBase { - - /** - * Unused variable to allow for otherwise useless __construct overrides. - * - * @var string - */ - protected string $internalTestType; - - /** - * Finds extensions in a Drupal installation. - * - * An extension is defined as a directory with an *.info.yml file in it. - * - * @param string $root - * Path to the root of the Drupal installation. - * - * @return string[] - * Associative array of extension paths, with extension name as keys. - */ - protected function findExtensionDirectories($root): array { - $paths = [ - $root . '/modules/custom', - $root . '/profiles/custom', - $root . '/themes/custom', - ]; - $extension_roots = array_filter($paths, 'file_exists'); - - $extension_directories = array_map('drupal_phpunit_find_extension_directories', $extension_roots); - return array_reduce($extension_directories, 'array_merge', []); - } - - /** - * Find and add tests to the suite for core and any extensions. - * - * @param string $root - * Path to the root of the Drupal installation. - * @param string $suite_namespace - * SubNamespace used to separate test suite. Examples: Unit, Functional. - */ - protected function addTestsBySuiteNamespace($root, $suite_namespace): void { - foreach ($this->findExtensionDirectories($root) 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/src/TestSuite/Functional.php b/src/TestSuite/Functional.php deleted file mode 100644 index a7178978ddedc2f4af81851f1ea066fac958e4ae..0000000000000000000000000000000000000000 --- a/src/TestSuite/Functional.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace LakeDrops\DrupalDevelopmentEnvironment\TestSuite; - -require_once __DIR__ . '/Base.php'; - -/** - * Discovers tests for the functional test suite. - */ -class Functional extends Base { - - /** - * {@inheritdoc} - */ - final public function __construct($theClass = '', string $name = '') { - parent::__construct($theClass, $name); - $this->internalTestType = 'functional'; - } - - /** - * Factory method which loads up a suite with all functional tests. - * - * @return static - * The test suite. - */ - public static function suite(): static { - $root = dirname(__DIR__, 5) . '/web'; - - $suite = new static('functional'); - $suite->addTestsBySuiteNamespace($root, 'Functional'); - - return $suite; - } - -} diff --git a/src/TestSuite/FunctionalJavascript.php b/src/TestSuite/FunctionalJavascript.php deleted file mode 100644 index 9d7fdf87aa76a23dafa697e3f8cd803a5fb25dfe..0000000000000000000000000000000000000000 --- a/src/TestSuite/FunctionalJavascript.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace LakeDrops\DrupalDevelopmentEnvironment\TestSuite; - -require_once __DIR__ . '/Base.php'; - -/** - * Discovers tests for the functional test suite. - */ -class FunctionalJavascript extends Base { - - /** - * {@inheritdoc} - */ - final public function __construct($theClass = '', string $name = '') { - parent::__construct($theClass, $name); - $this->internalTestType = 'functional javascript'; - } - - /** - * Factory method which loads up a suite with all functional tests. - * - * @return static - * The test suite. - */ - public static function suite(): static { - $root = dirname(__DIR__, 5) . '/web'; - - $suite = new static('functional-javascript'); - $suite->addTestsBySuiteNamespace($root, 'FunctionalJavascript'); - - return $suite; - } - -} diff --git a/src/TestSuite/Kernel.php b/src/TestSuite/Kernel.php deleted file mode 100644 index 457bdfc8694e0eab0bb72f71524a6e88770530db..0000000000000000000000000000000000000000 --- a/src/TestSuite/Kernel.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace LakeDrops\DrupalDevelopmentEnvironment\TestSuite; - -require_once __DIR__ . '/Base.php'; - -/** - * Discovers tests for the unit test suite. - */ -class Kernel extends Base { - - /** - * {@inheritdoc} - */ - final public function __construct($theClass = '', string $name = '') { - parent::__construct($theClass, $name); - $this->internalTestType = 'kernel'; - } - - /** - * Factory method which loads up a suite with all unit tests. - * - * @return static - * The test suite. - */ - public static function suite(): static { - $root = dirname(__DIR__, 5) . '/web'; - - $suite = new static('kernel'); - $suite->addTestsBySuiteNamespace($root, 'Kernel'); - - return $suite; - } - -} diff --git a/src/TestSuite/Unit.php b/src/TestSuite/Unit.php deleted file mode 100644 index 4a0d09a214ab85a8c9635ef2daf0a08760763ee0..0000000000000000000000000000000000000000 --- a/src/TestSuite/Unit.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace LakeDrops\DrupalDevelopmentEnvironment\TestSuite; - -require_once __DIR__ . '/Base.php'; - -/** - * Discovers tests for the unit test suite. - */ -class Unit extends Base { - - /** - * {@inheritdoc} - */ - final public function __construct($theClass = '', string $name = '') { - parent::__construct($theClass, $name); - $this->internalTestType = 'unit'; - } - - /** - * Factory method which loads up a suite with all unit tests. - * - * @return static - * The test suite. - */ - public static function suite(): static { - $root = dirname(__DIR__, 5) . '/web'; - - $suite = new static('unit'); - $suite->addTestsBySuiteNamespace($root, 'Unit'); - - return $suite; - } - -} diff --git a/templates/tests/phpunit.xml.dist b/templates/tests/phpunit.xml.dist index 529acec5d7067d3fea8a82796065dadaf8f821a9..ee2050f85b6264c36aab90417b358166c7c655a8 100644 --- a/templates/tests/phpunit.xml.dist +++ b/templates/tests/phpunit.xml.dist @@ -35,16 +35,19 @@ </php> <testsuites> <testsuite name="unit"> - <file>../vendor/lakedrops/drupal-development-environment/src/TestSuite/Unit.php</file> + <file>./tests/TestSuites/UnitTestSuite.php</file> </testsuite> <testsuite name="kernel"> - <file>../vendor/lakedrops/drupal-development-environment/src/TestSuite/Kernel.php</file> + <file>./tests/TestSuites/KernelTestSuite.php</file> </testsuite> <testsuite name="functional"> - <file>../vendor/lakedrops/drupal-development-environment/src/TestSuite/Functional.php</file> + <file>./tests/TestSuites/FunctionalTestSuite.php</file> </testsuite> <testsuite name="functional-javascript"> - <file>../vendor/lakedrops/drupal-development-environment/src/TestSuite/FunctionalJavascript.php</file> + <file>./tests/TestSuites/FunctionalJavascriptTestSuite.php</file> + </testsuite> + <testsuite name="build"> + <file>./tests/TestSuites/BuildTestSuite.php</file> </testsuite> </testsuites> <listeners>