Commit 81ecce42 authored by catch's avatar catch
Browse files

Issue #3122961 by mondrake: PHPUnit\Framework\TestCase::__construct() should not be extended

(cherry picked from commit 363a6611)
parent 663762f3
......@@ -76,6 +76,8 @@ abstract class InstallerTestBase extends BrowserTestBase {
* {@inheritdoc}
*/
protected function setUp() {
parent::setUpAppRoot();
$this->isInstalled = FALSE;
$this->setupBaseUrl();
......
......@@ -117,18 +117,6 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
*/
protected $strictConfigSchema = FALSE;
/**
* Constructs an UpdatePathTestCase object.
*
* @param $test_id
* (optional) The ID of the test. Tests with the same id are reported
* together.
*/
public function __construct($test_id = NULL) {
parent::__construct($test_id);
$this->zlibInstalled = function_exists('gzopen');
}
/**
* Overrides WebTestBase::setUp() for update testing.
*
......@@ -138,6 +126,9 @@ public function __construct($test_id = NULL) {
* container that would normally be done via the installer.
*/
protected function setUp() {
parent::setUpAppRoot();
$this->zlibInstalled = function_exists('gzopen');
$request = Request::createFromGlobals();
// Boot up Drupal into a state where calling the database API is possible.
......
......@@ -212,15 +212,6 @@ abstract class BrowserTestBase extends TestCase {
*/
protected $originalContainer;
/**
* {@inheritdoc}
*/
public function __construct($name = NULL, array $data = [], $dataName = '') {
parent::__construct($name, $data, $dataName);
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
}
/**
* Initializes Mink sessions.
*/
......@@ -397,6 +388,8 @@ protected function registerSessions() {}
protected function setUp() {
parent::setUp();
$this->setUpAppRoot();
// Allow tests to compare MarkupInterface objects via assertEquals().
$this->registerComparator(new MarkupInterfaceComparator());
......@@ -418,6 +411,15 @@ protected function setUp() {
$this->addToAssertionCount(1);
}
/**
* Sets up the root application path.
*/
protected function setUpAppRoot(): void {
if ($this->root === NULL) {
$this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
}
}
/**
* Ensures test files are deletable.
*
......
......@@ -174,8 +174,6 @@ public static function getSkippedDeprecations() {
"The \"Drupal\Tests\Listeners\DrupalListener\" class implements \"PHPUnit\Framework\TestListener\" that is deprecated Use the `TestHook` interfaces instead.",
"The \"Drupal\Tests\Listeners\DrupalListener\" class uses \"PHPUnit\Framework\TestListenerDefaultImplementation\" that is deprecated The `TestListener` interface is deprecated.",
"The \"PHPUnit\Framework\TestSuite\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\TestSuites\TestSuiteBase\".",
"The \"PHPUnit\Framework\TestCase::__construct()\" method is considered internal This method is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not extend it from \"Drupal\Tests\BrowserTestBase\".",
"The \"PHPUnit\Framework\TestCase::__construct()\" method is considered internal This method is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not extend it from \"Drupal\FunctionalTests\Update\UpdatePathTestBase\".",
];
}
......
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