Verified Commit 7e4ecad5 authored by Dave Long's avatar Dave Long
Browse files

Issue #3354063 by Spokje, longwave, mondrake, Gauravvvv, joachim: Fix missing...

Issue #3354063 by Spokje, longwave, mondrake, Gauravvvv, joachim: Fix missing call to parent::setUp() in remaining tests
parent e9ae88f8
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -46,17 +46,24 @@ protected function prepareEnvironment() {
  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
  public function setUpSettings() {
    // During set up an UnmetDependenciesException should be thrown, which will
    // be re-thrown by TestHttpClientMiddleware as a standard Exception.
    try {
      parent::setUp();
      parent::setUpSettings();
    }
    catch (\Exception $exception) {
      $this->expectedException = $exception;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setUpSite() {
    // This step can no longer be reached.
  }

  /**
   * Copy the testing_config_overrides install profile.
   *
+0 −20
Original line number Diff line number Diff line
@@ -915,11 +915,6 @@ parameters:
			count: 2
			path: modules/config/src/Form/ConfigSingleImportForm.php

		-
			message: "#^Missing call to parent\\:\\:setUp\\(\\) method\\.$#"
			count: 1
			path: modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php

		-
			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
			count: 1
@@ -2705,16 +2700,6 @@ parameters:
			count: 1
			path: tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php

		-
			message: "#^Missing call to parent\\:\\:setUp\\(\\) method\\.$#"
			count: 1
			path: tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php

		-
			message: "#^Missing call to parent\\:\\:setUp\\(\\) method\\.$#"
			count: 1
			path: tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php

		-
			message: "#^Variable \\$found might not be defined\\.$#"
			count: 1
@@ -2730,11 +2715,6 @@ parameters:
			count: 2
			path: tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php

		-
			message: "#^Missing call to parent\\:\\:setUp\\(\\) method\\.$#"
			count: 1
			path: tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php

		-
			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
			count: 4
+8 −18
Original line number Diff line number Diff line
@@ -89,20 +89,9 @@ protected function installParameters() {
  }

  /**
   * {@inheritdoc}
   * We are testing the installer, so set up a minimal environment for that.
   */
  protected function setUp(): void {
    parent::setUpAppRoot();

    $this->isInstalled = FALSE;

    $this->setupBaseUrl();

    $this->prepareDatabasePrefix();

    // Install Drupal test site.
    $this->prepareEnvironment();

  public function installDrupal() {
    // Define information about the user 1 account.
    $this->rootUser = new UserSession([
      'uid' => 1,
@@ -157,12 +146,13 @@ protected function setUp(): void {
    $this->container
      ->setParameter('app.root', DRUPAL_ROOT);
    \Drupal::setContainer($this->container);
  }

    // Setup Mink.
    $this->initMink();

    // Set up the browser test output file.
    $this->initBrowserOutputFile();
  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    $this->visitInstaller();

+20 −43
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

use Drupal\Component\Utility\Crypt;
use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestRunnerKernel;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Database\Database;
use Drupal\Core\DependencyInjection\ContainerBuilder;
@@ -118,26 +117,23 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
  protected $strictConfigSchema = FALSE;

  /**
   * Overrides BrowserTestBase::setUp() for update testing.
   * {@inheritdoc}
   */
  protected function setUp(): void {
    $this->zlibInstalled = function_exists('gzopen');

    parent::setUp();
  }

  /**
   * Overrides BrowserTestBase::installDrupal() for update testing.
   *
   * The main difference in this method is that rather than performing the
   * installation via the installer, a database is loaded. Additional work is
   * then needed to set various things such as the config directories and the
   * container that would normally be done via the installer.
   */
  protected function setUp(): void {
    parent::setUpAppRoot();
    $this->zlibInstalled = function_exists('gzopen');

    $request = Request::createFromGlobals();

    // Boot up Drupal into a state where calling the database API is possible.
    // This is used to initialize the database system, so we can load the dump
    // files.
    $autoloader = require $this->root . '/autoload.php';
    $kernel = TestRunnerKernel::createFromRequest($request, $autoloader);
    $kernel->loadLegacyIncludes();

  public function installDrupal() {
    // Set the update URL. This must be set here rather than in
    // self::__construct() or the old URL generator will leak additional test
    // sites. Additionally, we need to prevent the path alias processor from
@@ -145,20 +141,21 @@ protected function setUp(): void {
    // the updates.
    $this->updateUrl = Url::fromRoute('system.db_update', [], ['path_processing' => FALSE]);

    $this->setupBaseUrl();

    // Install Drupal test site.
    $this->prepareEnvironment();
    $this->runDbTasks();

    // We are going to set a missing zlib requirement property for usage
    // during the performUpgrade() and tearDown() methods. Also set that the
    // tests failed.
    if (!$this->zlibInstalled) {
      parent::setUp();
      return;
    }
    $this->installDrupal();

    $this->initUserSession();
    $this->prepareSettings();
    $this->doInstall();
    $this->initSettings();

    $request = Request::createFromGlobals();
    $container = $this->initKernel($request);
    $this->initConfig($container);

    // Add the config directories to settings.php.
    $sync_directory = Settings::get('config_sync_directory');
@@ -175,26 +172,6 @@ protected function setUp(): void {
    $this->replaceUser1();

    require_once $this->root . '/core/includes/update.inc';

    // Setup Mink.
    $this->initMink();

    // Set up the browser test output file.
    $this->initBrowserOutputFile();
  }

  /**
   * {@inheritdoc}
   */
  public function installDrupal() {
    $this->initUserSession();
    $this->prepareSettings();
    $this->doInstall();
    $this->initSettings();

    $request = Request::createFromGlobals();
    $container = $this->initKernel($request);
    $this->initConfig($container);
  }

  /**
+2 −6
Original line number Diff line number Diff line
@@ -21,12 +21,8 @@ class DrupalKernelTest extends KernelTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    // Do not invoke KernelTestBase::setUp(), since that would set up further
    // environment aspects, which would distort this test, because it tests the
    // DrupalKernel (re-)building itself.
    $this->root = static::getDrupalRoot();
    $this->bootEnvironment();
  protected function bootKernel() {
    // Do not boot the kernel, because we are testing aspects of this process.
  }

  /**
Loading