TestSiteReleaseLocksCommand.php 984 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Drupal\TestSite\Commands;
  3. use Drupal\Core\Test\TestDatabase;
  4. use Symfony\Component\Console\Command\Command;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. /**
  8. * Command to release all test site database prefix locks.
  9. *
  10. * Note that this command can't be safely tested by DrupalCI without potentially
  11. * causing random failures.
  12. *
  13. * @internal
  14. */
  15. class TestSiteReleaseLocksCommand extends Command {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected function configure() {
  20. $this->setName('release-locks')
  21. ->setDescription('Releases all test site locks')
  22. ->setHelp('The locks ensure test site database prefixes are not reused.');
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. protected function execute(InputInterface $input, OutputInterface $output) {
  28. TestDatabase::releaseAllTestLocks();
  29. $output->writeln('<info>Successfully released all the test database locks</info>');
  30. return 0;
  31. }
  32. }