Skip to content
Snippets Groups Projects

Merging develop into main

Merged GitLab CI requested to merge develop into main
9 files
+ 13
211
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 0
62
<?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));
}
}
}
}
Loading