public function SchedulerFunctionalTest::testRevisioning in Scheduler 7
Tests the creation of new revisions on scheduling.
File
- tests/
scheduler.test, line 303 - Scheduler module test case file.
Class
- SchedulerFunctionalTest
- Tests the scheduler interface.
Code
public function testRevisioning() {
// Create a scheduled node that is not automatically revisioned.
$created = strtotime('-2 day', REQUEST_TIME);
$settings = array(
'revision' => 0,
'created' => $created,
);
$node = $this
->drupalCreateNode($settings);
// First test scheduled publication with revisioning disabled.
$node = $this
->schedule($node);
$this
->assertRevisionCount($node->nid, 1, 'No new revision was created when a node was published with revisioning disabled.');
// Test scheduled unpublication.
$node = $this
->schedule($node, 'unpublish');
$this
->assertRevisionCount($node->nid, 1, 'No new revision was created when a node was unpublished with revisioning disabled.');
// Enable revisioning.
variable_set('scheduler_publish_revision_page', 1);
variable_set('scheduler_unpublish_revision_page', 1);
// Test scheduled publication with revisioning enabled.
$node = $this
->schedule($node);
$this
->assertRevisionCount($node->nid, 2, 'A new revision was created when revisioning is enabled.');
$expected_message = t('Node published by Scheduler on @now. Previous creation date was @date.', array(
'@now' => format_date(REQUEST_TIME, 'short'),
'@date' => format_date($created, 'short'),
));
$this
->assertRevisionLogMessage($node->nid, $expected_message, 'The correct message was found in the node revision log after scheduled publishing.');
// Test scheduled unpublication with revisioning enabled.
$node = $this
->schedule($node, 'unpublish');
$this
->assertRevisionCount($node->nid, 3, 'A new revision was created when a node was unpublished with revisioning enabled.');
$expected_message = t('Node unpublished by Scheduler on @now. Previous change date was @date.', array(
'@now' => format_date(REQUEST_TIME, 'short'),
'@date' => format_date(REQUEST_TIME, 'short'),
));
$this
->assertRevisionLogMessage($node->nid, $expected_message, 'The correct message was found in the node revision log after scheduled unpublishing.');
}