function CronCommandTest::testCronExceptions

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Command/CronCommandTest.php \Drupal\Tests\system\Functional\Command\CronCommandTest::testCronExceptions()

Make sure exceptions thrown on hook_cron() don't affect other modules.

File

core/modules/system/tests/src/Functional/Command/CronCommandTest.php, line 50

Class

CronCommandTest
Tests cron runs as a console command.

Namespace

Drupal\Tests\system\Functional\Command

Code

public function testCronExceptions() : void {
  \Drupal::state()->delete('common_test.cron');
  $command = new CronCommand($this->container
    ->get('cron'));
  $tester = new CommandTester($command);
  $code = $tester->execute([]);
  $this->assertStringContainsString('Cron ran successfully.', $tester->getDisplay());
  $this->assertEquals(Command::SUCCESS, $code);
}

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