diff -u b/core/tests/Drupal/Setup/Commands/TestTeardownCommand.php b/core/tests/Drupal/Setup/Commands/TestTeardownCommand.php --- b/core/tests/Drupal/Setup/Commands/TestTeardownCommand.php +++ b/core/tests/Drupal/Setup/Commands/TestTeardownCommand.php @@ -76,6 +76,8 @@ * The database URL. * @param $app_root * The app root. + * + * @see \Drupal\Tests\BrowserTestBase::cleanupEnvironment() */ public function teardown($db_prefix, $db_url, $app_root) { // Connect to the test database. diff -u b/core/tests/Drupal/Tests/Setup/Commands/SetupDrupalTestScriptTest.php b/core/tests/Drupal/Tests/Setup/Commands/SetupDrupalTestScriptTest.php --- b/core/tests/Drupal/Tests/Setup/Commands/SetupDrupalTestScriptTest.php +++ b/core/tests/Drupal/Tests/Setup/Commands/SetupDrupalTestScriptTest.php @@ -43,12 +43,17 @@ $phpBinaryFinder = new PhpExecutableFinder(); $phpBinaryPath = $phpBinaryFinder->find(); + // Create a connection to the DB configured in SIMPLETEST_DB. + $connection = Database::getConnection('default', $this->addTestDatabase('')); + $table_count = count($connection->schema()->findTables('%')); + $command_line = $phpBinaryPath . ' core/scripts/setup-drupal-test.php setup-drupal-test --setup_class "this-class-does-not-exist" --db_url "' . getenv('SIMPLETEST_DB') . '"'; $process = new Process($command_line, $this->root); $process->run(); $this->assertContains('There was a problem loading this-class-does-not-exist', $process->getErrorOutput()); $this->assertSame(1, $process->getExitCode()); + $this->assertSame($table_count, count($connection->schema()->findTables('%')), 'No additional tables created in the database'); } /** @@ -58,12 +63,17 @@ $phpBinaryFinder = new PhpExecutableFinder(); $phpBinaryPath = $phpBinaryFinder->find(); + // Create a connection to the DB configured in SIMPLETEST_DB. + $connection = Database::getConnection('default', $this->addTestDatabase('')); + $table_count = count($connection->schema()->findTables('%')); + $command_line = $phpBinaryPath . ' core/scripts/setup-drupal-test.php setup-drupal-test --setup_class "' . static::class . '" --db_url "' . getenv('SIMPLETEST_DB') . '"'; $process = new Process($command_line, $this->root); $process->run(); $this->assertContains('You need to define a class implementing \Drupal\Setup\TestSetupInterface', $process->getErrorOutput()); $this->assertSame(1, $process->getExitCode()); + $this->assertSame($table_count, count($connection->schema()->findTables('%')), 'No additional tables created in the database'); } /** @@ -95,7 +105,7 @@ $key = $this->addTestDatabase($db_prefix); $this->assertGreaterThan(0, count(Database::getConnection('default', $key)->schema()->findTables('%'))); $test_database = new TestDatabase($db_prefix); - $test_file = $test_database->getTestSitePath() . DIRECTORY_SEPARATOR . '.htkey'; + $test_file = $this->root . DIRECTORY_SEPARATOR . $test_database->getTestSitePath() . DIRECTORY_SEPARATOR . '.htkey'; $this->assertFileExists($test_file); // Install another site so we can ensure tear down only removes one site at @@ -120,7 +130,7 @@ // Ensure the other sites tables and files still exist. $this->assertGreaterThan(0, count(Database::getConnection('default', $other_key)->schema()->findTables('%'))); $test_database = new TestDatabase($other_db_prefix); - $test_file = $test_database->getTestSitePath() . DIRECTORY_SEPARATOR . '.htkey'; + $test_file = $this->root . DIRECTORY_SEPARATOR . $test_database->getTestSitePath() . DIRECTORY_SEPARATOR . '.htkey'; $this->assertFileExists($test_file); // Now test the tear down process as well.