You are here

public function SchedulerDrushTest::testDrushCronMessages in Scheduler 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/SchedulerDrushTest.php \Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronMessages()

Tests the Scheduler Drush messages.

File

tests/src/Functional/SchedulerDrushTest.php, line 19

Class

SchedulerDrushTest
Tests the Drush commands provided by Scheduler.

Namespace

Drupal\Tests\scheduler\Functional

Code

public function testDrushCronMessages() {

  // Run the plain command using the full scheduler:cron command name, and
  // check that all of the output messages are shown.
  $this
    ->drush('scheduler:cron');
  $messages = $this
    ->getErrorOutput();
  $this
    ->assertStringContainsString('Lightweight cron run activated by drush command', $messages, 'Starting dblog message not found', TRUE);
  $this
    ->assertStringContainsString('Lightweight cron run completed', $messages, 'Ending dblog message not found', TRUE);
  $this
    ->assertStringContainsString('Message: Scheduler lightweight cron completed', $messages, 'Drush message not found', TRUE);

  // Use the sch:cron alias and simulate the --nomsg parameter, then check
  // that the drush confirmation message is not shown.
  $this
    ->drush('sch:cron', [], [
    'nomsg' => TRUE,
  ]);
  $messages = $this
    ->getErrorOutput();
  $this
    ->assertStringNotContainsString('Message: Scheduler lightweight cron completed', $messages, '--nomsg parameter did not work', TRUE);

  // Use the alternative alias sch-cron and add the --nolog parameter, then
  // check that the dblog messages are not shown.
  $this
    ->drush('sch-cron', [], [
    'nolog' => TRUE,
  ]);
  $messages = $this
    ->getErrorOutput();
  $this
    ->assertStringNotContainsString('Lightweight cron run activated by drush command', $messages, '--nolog parameter did not work for starting message', TRUE);
  $this
    ->assertStringNotContainsString('Lightweight cron run completed', $messages, '--nolog parameter did not work for ending message', TRUE);
}