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

Issue #3196507 by mondrake, longwave, mxr576, alexpott:...

Issue #3196507 by mondrake, longwave, mxr576, alexpott: KernelTestBaseTest::tearDown() should not perform assertions
parent ccca0abb
Loading
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
use Drupal\user\Entity\Role;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\visitor\vfsStreamStructureVisitor;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use Psr\Http\Client\ClientExceptionInterface;

/**
@@ -255,6 +256,13 @@ public function testLocalTimeZone(): void {
    $this->assertEquals('Australia/Sydney', date_default_timezone_get());
  }

  /**
   * Tests that ::tearDown() does not perform assertions.
   */
  #[DoesNotPerformAssertions]
  public function testTearDown(): void {
  }

  /**
   * {@inheritdoc}
   */
@@ -266,18 +274,20 @@ protected function tearDown(): void {
    // the tables.
    $connection = Database::getConnection();
    if ($connection->databaseType() === 'sqlite') {
      $result = $connection->query("SELECT name FROM " . $this->databasePrefix .
      $tables = $connection->query("SELECT name FROM " . $this->databasePrefix .
        ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
          ':type' => 'table',
          ':table_name' => '%',
          ':pattern' => 'sqlite_%',
        ]
      )->fetchAllKeyed(0, 0);
      $this->assertEmpty($result, 'All test tables have been removed.');
    }
    else {
      $tables = $connection->schema()->findTables($this->databasePrefix . '%');
      $this->assertEmpty($tables, 'All test tables have been removed.');
    }

    if (!empty($tables)) {
      throw new \RuntimeException("Not all test tables were removed");
    }
  }