Skip to content
Snippets Groups Projects
Unverified Commit c677d4f4 authored by Alex Pott's avatar Alex Pott
Browse files

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
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment