protected function TestSiteTearDownCommand::execute in Drupal 9        
                          
                  
                        Same name and namespace in other branches
- 8 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\Commands
Code
protected function execute(InputInterface $input, OutputInterface $output) {
  $db_prefix = $input
    ->getArgument('db-prefix');
  
  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'.");
    
    $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}");
  
  $this
    ->tearDown($test_database, $db_url);
  
  if (!$input
    ->getOption('keep-lock')) {
    $test_database
      ->releaseLock();
  }
  $output
    ->writeln("<info>Successfully uninstalled {$db_prefix} test site</info>");
  return 0;
}