protected function SchedulerRevisioningTest::schedule in Scheduler 8
Simulates the scheduled (un)publication of a node.
Parameters
\Drupal\node\NodeInterface $node: The node to schedule.
string $action: The action to perform: either 'publish' or 'unpublish'. Defaults to 'publish'.
Return value
\Drupal\node\NodeInterface The updated node, after scheduled (un)publication via a cron run.
2 calls to SchedulerRevisioningTest::schedule()
- SchedulerRevisioningTest::testAlterCreationDate in tests/
src/ Functional/ SchedulerRevisioningTest.php - Tests the 'touch' option to alter the node created date during publishing.
- SchedulerRevisioningTest::testRevisioning in tests/
src/ Functional/ SchedulerRevisioningTest.php - Tests the creation of new revisions on scheduling.
File
- tests/
src/ Functional/ SchedulerRevisioningTest.php, line 26
Class
- SchedulerRevisioningTest
- Tests revision options when Scheduler publishes or unpublishes content.
Namespace
Drupal\Tests\scheduler\FunctionalCode
protected function schedule(NodeInterface $node, $action = 'publish') {
// Simulate scheduling by setting the (un)publication date in the past and
// running cron.
$node->{$action . '_on'} = strtotime('-5 hour', $this->requestTime);
$node
->save();
scheduler_cron();
$this->nodeStorage
->resetCache([
$node
->id(),
]);
return $this->nodeStorage
->load($node
->id());
}