public function SchedulerDrushTest::testDrushCronPublishing in Scheduler 8
Same name and namespace in other branches
- 2.x tests/src/Functional/SchedulerDrushTest.php \Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronPublishing()
Tests scheduled publishing via Drush command.
File
- tests/
src/ Functional/ SchedulerDrushTest.php, line 45
Class
- SchedulerDrushTest
- Tests the Drush commands provided by Scheduler.
Namespace
Drupal\Tests\scheduler\FunctionalCode
public function testDrushCronPublishing() {
// Create a node which is scheduled for publishing.
$title1 = $this
->randomMachineName(20);
$this
->drupalCreateNode([
'title' => $title1,
'type' => $this->type,
'publish_on' => strtotime('-3 hours'),
]);
// Create a node which is scheduled for unpublishing.
$title2 = $this
->randomMachineName(20);
$this
->drupalCreateNode([
'title' => $title2,
'type' => $this->type,
'unpublish_on' => strtotime('-2 hours'),
]);
// Run Scheduler's drush cron command and check that the expected publishing
// and unpublishing messages are found.
$this
->drush('scheduler:cron');
$messages = $this
->getErrorOutput();
$this
->assertStringContainsString(sprintf('%s: scheduled publishing of %s', $this->typeName, $title1), $messages, 'Scheduled publishing message not found', TRUE);
$this
->assertStringContainsString(sprintf('%s: scheduled unpublishing of %s', $this->typeName, $title2), $messages, 'Scheduled unpublishing message not found', TRUE);
}