diff --git a/core/tests/Drupal/KernelTests/Setup/Commands/SetupDrupalTestScriptTest.php b/core/tests/Drupal/KernelTests/Setup/Commands/SetupDrupalTestScriptTest.php index b8236f9b3f..6f3c2f3800 100644 --- a/core/tests/Drupal/KernelTests/Setup/Commands/SetupDrupalTestScriptTest.php +++ b/core/tests/Drupal/KernelTests/Setup/Commands/SetupDrupalTestScriptTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Setup\Commands; +use Drupal\Core\Database\Database; use Drupal\KernelTests\KernelTestBase; use Drupal\Setup\Commands\TestInstallationSetupApplication; use Drupal\Setup\SetupDrupalTestScript; @@ -96,6 +97,8 @@ public function testInstallScript() { $this->assertRegExp('/simpletest/', $app_tester->getDisplay()); $this->assertEqual(0, $app_tester->getStatusCode()); + list($test_db_prefix) = explode(':', $app_tester->getDisplay(), 2); + $http_client = new Client(); $request = (new Request('GET', getenv('SIMPLETEST_BASE_URL') . '/test-page')) ->withHeader('User-Agent', trim($app_tester->getDisplay())); @@ -105,15 +108,27 @@ public function testInstallScript() { $this->assertContains('Test page | Drupal', (string) $response->getBody()); // Now test the tear down process as well. + $this->assertHasTables(); $app_tester->run( [ 'command' => 'teardown-drupal-test', - 'db_prefix' => $this->databasePrefix, + 'db_prefix' => $test_db_prefix, ], [ 'interactive' => FALSE, ] ); + $this->assertHasNoTables(); + } + + public function assertHasTables() { + $tables = Database::getConnection()->schema()->findTables('%'); + $this->assertNotEmpty($tables); + } + + public function assertHasNoTables() { + $tables = Database::getConnection()->schema()->findTables('%'); + $this->assertEmpty($tables); } }