protected function TestSiteTearDownCommand::execute in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php \Drupal\TestSite\Commands\TestSiteTearDownCommand::execute()
- 10 core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php \Drupal\TestSite\Commands\TestSiteTearDownCommand::execute()
File
- core/
tests/ Drupal/ TestSite/ Commands/ TestSiteTearDownCommand.php, line 40
Class
- TestSiteTearDownCommand
- Command to tear down a test Drupal site.
Namespace
Drupal\TestSite\CommandsCode
protected function execute(InputInterface $input, OutputInterface $output) {
$db_prefix = $input
->getArgument('db-prefix');
// Validate the db_prefix argument.
try {
$test_database = new TestDatabase($db_prefix);
} catch (\InvalidArgumentException $e) {
$io = new SymfonyStyle($input, $output);
$io
->getErrorStyle()
->error("Invalid database prefix: {$db_prefix}\n\nValid database prefixes match the regular expression '/test(\\d+)\$/'. For example, 'test12345678'.");
// Display the synopsis of the command like Composer does.
$output
->writeln(sprintf('<info>%s</info>', sprintf($this
->getSynopsis(), $this
->getName())), OutputInterface::VERBOSITY_QUIET);
return 1;
}
$db_url = $input
->getOption('db-url');
putenv("SIMPLETEST_DB={$db_url}");
// Handle the cleanup of the test site.
$this
->tearDown($test_database, $db_url);
// Release the test database prefix lock.
if (!$input
->getOption('keep-lock')) {
$test_database
->releaseLock();
}
$output
->writeln("<info>Successfully uninstalled {$db_prefix} test site</info>");
return 0;
}