Commit 73a154ae authored by catch's avatar catch
Browse files

Issue #3253639 by tedbow, longwave:...

Issue #3253639 by tedbow, longwave: \Drupal\Tests\update\Functional\UpdateTestBase::setUp is not needed for most child classes and makes the test harder to understand

(cherry picked from commit 42a48a2e)
parent 9a8c5ff7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *
 * @group update
 */
class FileTransferAuthorizeFormTest extends UpdateTestBase {
class FileTransferAuthorizeFormTest extends UpdateUploaderTestBase {

  /**
   * Modules to enable.
+0 −23
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\update\Functional;

use Drupal\Core\DrupalKernel;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;

@@ -54,28 +53,6 @@ abstract class UpdateTestBase extends BrowserTestBase {
   */
  protected $updateProject;

  protected function setUp() {
    parent::setUp();

    // Change the root path which Update Manager uses to install and update
    // projects to be inside the testing site directory. See
    // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
    // test child site.
    $request = \Drupal::request();
    $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
    $this->container->get('update.root')->set($update_root);

    // Create the directories within the root path within which the Update
    // Manager will install projects.
    foreach (drupal_get_updaters() as $updater_info) {
      $updater = $updater_info['class'];
      $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
      if (!is_dir($install_directory)) {
        mkdir($install_directory);
      }
    }
  }

  /**
   * Refreshes the update status based on the desired available update scenario.
   *
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
 *
 * @group update
 */
class UpdateUploadTest extends UpdateTestBase {
class UpdateUploadTest extends UpdateUploaderTestBase {

  use TestFileCreationTrait {
    getTestFiles as drupalGetTestFiles;
+37 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\update\Functional;

use Drupal\Core\DrupalKernel;

/**
 * Base test class for tests that test project upload functionality.
 */
class UpdateUploaderTestBase extends UpdateTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    // Change the root path which Update Manager uses to install and update
    // projects to be inside the testing site directory. See
    // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
    // test child site.
    $request = \Drupal::request();
    $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
    $this->container->get('update.root')->set($update_root);

    // Create the directories within the root path within which the Update
    // Manager will install projects.
    foreach (drupal_get_updaters() as $updater_info) {
      $updater = $updater_info['class'];
      $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
      if (!is_dir($install_directory)) {
        mkdir($install_directory);
      }
    }
  }

}