Unverified Commit c677d4f4 authored by alexpott's avatar alexpott

Issue #2981678 by Mile23, Lendude, alexpott, dawehner: Fail PHPUnit-based...

Issue #2981678 by Mile23, Lendude, alexpott, dawehner: Fail PHPUnit-based tests which still inherit from WTB/TB
parent e911b2e9
......@@ -4,7 +4,7 @@
use Drupal\Core\Url;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
use Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase;
use Drupal\system\Entity\Menu;
/**
......
......@@ -248,6 +248,20 @@ public function __construct($test_id = NULL) {
$this->testId = $test_id;
}
/**
* Fail the test if it belongs to a PHPUnit-based framework.
*
* This would probably be caused by automated test conversions such as those
* in https://www.drupal.org/project/drupal/issues/2770921.
*/
public function checkTestHierarchyMismatch() {
// We can use getPhpunitTestSuite() because it uses a regex on the class'
// namespace to deduce the PHPUnit test suite.
if (TestDiscovery::getPhpunitTestSuite(get_class($this)) !== FALSE) {
$this->fail(get_class($this) . ' incorrectly subclasses ' . __CLASS__ . ', it should probably extend \Drupal\Tests\BrowserTestBase instead.');
}
}
/**
* Performs setup tasks before each individual test method is run.
*/
......@@ -864,6 +878,7 @@ protected function verbose($message) {
* methods during debugging.
*/
public function run(array $methods = []) {
$this->checkTestHierarchyMismatch();
$class = get_class($this);
if ($missing_requirements = $this->checkRequirements()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment