diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php index 699f26f87dc..4268fbce6b4 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php @@ -76,6 +76,8 @@ abstract class InstallerTestBase extends BrowserTestBase { * {@inheritdoc} */ protected function setUp() { + parent::setUpAppRoot(); + $this->isInstalled = FALSE; $this->setupBaseUrl(); diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php index bf893ef8c23..c3ca2b9b51b 100644 --- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php +++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php @@ -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 @@ abstract class UpdatePathTestBase extends BrowserTestBase { * 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. diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 7226e9a4a6e..de215ad0c22 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -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 @@ abstract class BrowserTestBase extends TestCase { protected function setUp() { parent::setUp(); + $this->setUpAppRoot(); + // Allow tests to compare MarkupInterface objects via assertEquals(). $this->registerComparator(new MarkupInterfaceComparator()); @@ -418,6 +411,15 @@ abstract class BrowserTestBase extends TestCase { $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. * diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 7621269ca59..e4f3196ba15 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -174,8 +174,6 @@ trait DeprecationListenerTrait { "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\".", ]; }