class CacheRebuildCommandTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Core/Console/CacheRebuildCommandTest.php \Drupal\FunctionalTests\Core\Console\CacheRebuildCommandTest

Tests the cache:rebuild command.

Attributes

#[Group('Console')] #[RunTestsInSeparateProcesses] #[CoversClass(CacheRebuildCommand::class)]

Hierarchy

Expanded class hierarchy of CacheRebuildCommandTest

File

core/tests/Drupal/FunctionalTests/Core/Console/CacheRebuildCommandTest.php, line 21

Namespace

Drupal\FunctionalTests\Core\Console
View source
class CacheRebuildCommandTest extends BrowserTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * Tests the cache:rebuild command.
   */
  public function testConsoleCommand() : void {
    $command = new CacheRebuildCommand(new ClassLoader());
    $tester = new CommandTester($command);
    $code = $tester->execute([]);
    $this->assertStringContainsString('All caches have been rebuilt.', $tester->getDisplay());
    $this->assertEquals(Command::SUCCESS, $code);
    // Cache rebuild includes utility.inc, which sets an error handler. This
    // sets the error handler to the test bootstrap handler avoid a risky test
    // warning: "Test code or tested code removed error handlers other than its
    // own".
    set_error_handler(new BootstrapErrorHandler(PhpUnitErrorHandler::instance()));
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.