diff --git a/core/drupalci.yml b/core/drupalci.yml index 7bd1ac71d2..78e3d74eef 100644 --- a/core/drupalci.yml +++ b/core/drupalci.yml @@ -18,7 +18,7 @@ build: # deprecated code. run_tests.phpunit: types: 'PHPUnit-Unit' - testgroups: 'image' + testgroups: '--all' suppress-deprecations: false halt-on-fail: false run_tests.kernel: diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandards.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandards.php new file mode 100644 index 0000000000..2527056bb4 --- /dev/null +++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandards.php @@ -0,0 +1,75 @@ +testClassName()); + + // Check for component tests extending a core test. + if (substr($event->testClassName(), 0, 22) == 'Drupal\Tests\Component') { + if ($class instanceof BrowserTestBase || $class instanceof KernelTestBase || $class instanceof UnitTestCase) { + throw new \LogicException('Component tests should not extend a core test base class'); + } + } + + // Check for incorrect visibility of the $modules property. + if ($class->hasProperty('modules') && !$class->getProperty('modules')->isProtected()) { + throw new \LogicException('The ' . $event->testClassName() . '::$modules property must be declared protected'); + } + } + +} diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/BeforeFirstTestMethodCalledSubscriber.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/BeforeFirstTestMethodCalledSubscriber.php new file mode 100644 index 0000000000..bb055378ed --- /dev/null +++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/BeforeFirstTestMethodCalledSubscriber.php @@ -0,0 +1,17 @@ +standards()->beforeFirstTestMethodCalledSubscriber($event); + } + +} diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/Subscriber.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/Subscriber.php new file mode 100644 index 0000000000..8eef5dfc2e --- /dev/null +++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit10/DrupalStandardsSubscriber/Subscriber.php @@ -0,0 +1,22 @@ +standards = $standards; + } + + protected function standards(): DrupalStandards { + return $this->standards; + } + +} diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index 7266aabdb1..9f517dbc07 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -9,6 +9,7 @@ use Drupal\Component\Assertion\Handle; use Drupal\TestTools\PhpUnitCompatibility\PhpUnit8\ClassWriter; +use Drupal\TestTools\PhpUnitCompatibility\PhpUnit10\DrupalStandards; use Drupal\TestTools\PhpUnitCompatibility\PhpUnit10\Logging\HtmlOutputLogger; use Drupal\TestTools\PhpUnitCompatibility\RunnerVersion; use PHPUnit\Util\Filesystem; @@ -183,8 +184,11 @@ class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElemen // if they weren't on already. Handle::register(); -// Functional tests HTML output logging. if (RunnerVersion::getMajor() > 9) { + // Process Drupal standards checks on the tests. + DrupalStandards::init(); + + // Functional tests HTML output logging. $browserTestOutputDirectory = getenv('BROWSERTEST_OUTPUT_DIRECTORY'); if ($browserTestOutputDirectory !== FALSE) { if (Filesystem::createDirectory($browserTestOutputDirectory)) {