diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt index ef6f39377a2693707c10e93f160bbbbdc22d595e..70ea630ca80da207ce3b72bdd8f6e203aa4b99b9 100644 --- a/.cspell-project-words.txt +++ b/.cspell-project-words.txt @@ -1,5 +1,6 @@ ahoyapi checkstyle +cspellmodule eslintmodule lakedrops mariadbtest @@ -15,9 +16,9 @@ phpmetricsmodule phpstanmodule phpunitgroup phpunitmodule +preparecorefordev projectname stylelintmodule -stylelintprepare stylelintrc traefik usessl diff --git a/ahoy.test.yml b/ahoy.test.yml index 4774f1bbb53cbe08c77cded7eee2b5b48622b54c..e1c0d20413a0ee76e488847685e7b640621985ca 100644 --- a/ahoy.test.yml +++ b/ahoy.test.yml @@ -79,10 +79,10 @@ commands: if [[ -f tests/junit/${module}.xml ]]; then JUNIT=--junit=tests/junit/${module}.xml; fi ahoy d4d exec vendor/bin/phpmetrics --report-html=tests/metrics/$module $JUNIT web/modules/contrib/$module $@ usage: PHP Metrics by module - stylelintprepare: + preparecorefordev: cmd: | /usr/local/bin/node_cmd yarn --cwd web/core add stylelint-junit-formatter $@ - usage: Prepare environment for style linter + usage: Prepare environment for other tests like style linter and cspell stylelintmodule: cmd: | module=$1 diff --git a/composer.json b/composer.json index 7edcb1f80821f533778072a8e570d7f75ebf525f..a29ff3c4d244a8cf024c0ab36b8dbd09da840a6f 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,6 @@ "drupal/schema_diff": "*", "drupal/webprofiler": "*", "lakedrops/ahoy": "*", - "lakedrops/behat4drupal": "*", "lakedrops/composer-json-utils": "*", "lakedrops/docker4drupal": "*", "lakedrops/dorgflow": "*", @@ -72,7 +71,8 @@ }, "config": { "allow-plugins": { - "lakedrops/*": false + "lakedrops/*": false, + "zodiacmedia/drupal-libraries-installer": false } }, "autoload": { 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>