Verified Commit fe682bee authored by Dave Long's avatar Dave Long
Browse files

test: #3573954 Move common code across Drupal base test suite classes to DrupalTestCaseTrait

By: mondrake
By: smustgrave
By: dcam
By: quietone
parent ff86b9f9
Loading
Loading
Loading
Loading
Loading
+0 −7
Changes for core/lib/Drupal/Core/Test/TestSetupTrait.php: 0 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -90,13 +90,6 @@ trait TestSetupTrait {
   */
  protected $databasePrefix;

  /**
   * The app root.
   *
   * @var string
   */
  protected $root;

  /**
   * The temporary file directory for the test environment.
   *
+0 −8
Changes for core/tests/Drupal/BuildTests/QuickStart/QuickStartTest.php: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -43,13 +43,6 @@ class QuickStartTest extends BuildTestBase {
   */
  protected $testDb;

  /**
   * The Drupal root directory.
   *
   * @var string
   */
  protected $root;

  /**
   * {@inheritdoc}
   */
@@ -57,7 +50,6 @@ protected function setUp(): void {
    parent::setUp();
    $php_executable_finder = new PhpExecutableFinder();
    $this->php = $php_executable_finder->find();
    $this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
    chdir($this->root);
    if (!is_writable("{$this->root}/sites/simpletest")) {
      $this->markTestSkipped('This test requires a writable sites/simpletest directory');
+0 −8
Changes for core/tests/Drupal/BuildTests/QuickStart/RecipeQuickStartTest.php: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -44,13 +44,6 @@ class RecipeQuickStartTest extends BuildTestBase {
   */
  protected TestDatabase $testDb;

  /**
   * The Drupal root directory.
   *
   * @var string
   */
  protected string $root;

  /**
   * {@inheritdoc}
   */
@@ -58,7 +51,6 @@ protected function setUp(): void {
    parent::setUp();
    $php_executable_finder = new PhpExecutableFinder();
    $this->php = (string) $php_executable_finder->find();
    $this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
    if (!is_writable("{$this->root}/sites/simpletest")) {
      $this->markTestSkipped('This test requires a writable sites/simpletest directory');
    }
+0 −1
Changes for core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ protected function setUp(): void {
    // Find the current SUT database driver from the connection info. If that
    // is not the one the test requires, skip before test database
    // initialization so to save cycles.
    $this->root = static::getDrupalRoot();
    chdir($this->root);
    $connectionInfo = $this->getDatabaseConnectionInfo();
    $test_class_parts = explode('\\', get_class($this));
+0 −23
Changes for core/tests/Drupal/KernelTests/KernelTestBase.php: 0 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -26,14 +26,11 @@
use Drupal\Tests\ExtensionListTestTrait;
use Drupal\Tests\HttpKernelUiHelperTrait;
use Drupal\Tests\RandomGeneratorTrait;
use Drupal\Tests\TestRequirementsTrait;
use Drupal\TestTools\Comparator\MarkupInterfaceComparator;
use Drupal\TestTools\Extension\Dump\DebugDump;
use Drupal\TestTools\Extension\SchemaInspector;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\visitor\vfsStreamPrintVisitor;
use PHPUnit\Framework\Attributes\After;
use PHPUnit\Framework\Attributes\BeforeClass;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
@@ -41,7 +38,6 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\VarDumper\VarDumper;

/**
 * Base class for functional integration tests.
@@ -102,7 +98,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
  use RandomGeneratorTrait;
  use ConfigTestTrait;
  use ExtensionListTestTrait;
  use TestRequirementsTrait;
  use ProphecyTrait;
  use BrowserHtmlDebugTrait;
  use HttpKernelUiHelperTrait;
@@ -172,13 +167,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
   */
  protected KeyValueMemoryFactory $keyValue;

  /**
   * The app root.
   *
   * @var string
   */
  protected $root;

  /**
   * Set to TRUE to strict check all configuration saved.
   *
@@ -213,16 +201,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
   */
  protected bool $usesSuperUserAccessPolicy;

  /**
   * Registers the dumper CLI handler when the DebugDump extension is enabled.
   */
  #[BeforeClass]
  public static function setDebugDumpHandler(): void {
    if (DebugDump::isEnabled()) {
      VarDumper::setHandler(DebugDump::class . '::cliHandler');
    }
  }

  /**
   * {@inheritdoc}
   */
@@ -236,7 +214,6 @@ protected function setUp(): void {
    // Allow tests to compare MarkupInterface objects via assertEquals().
    $this->registerComparator(new MarkupInterfaceComparator());

    $this->root = static::getDrupalRoot();
    chdir($this->root);
    $this->initFileCache();
    $this->bootEnvironment();
Loading