public function SchedulerFunctionalTest::testAlterCreationDate in Scheduler 7
Tests the 'touch' option to update the created date during publishing.
File
- tests/
scheduler.test, line 1005  - Scheduler module test case file.
 
Class
- SchedulerFunctionalTest
 - Tests the scheduler interface.
 
Code
public function testAlterCreationDate() {
  // Ensure nodes with past dates will be scheduled not published immediately.
  variable_set('scheduler_publish_past_date_page', 'schedule');
  // Create a node with a 'created' date two days in the past.
  $created = strtotime('-2 day', REQUEST_TIME);
  $settings = array(
    'type' => 'page',
    'created' => $created,
    'status' => FALSE,
  );
  $node = $this
    ->drupalCreateNode($settings);
  // Check that the node is not published.
  $this
    ->assertFalse($node->status, 'Before cron, the node is not published.');
  // Schedule the node for publishing and run cron.
  $node = $this
    ->schedule($node, 'publish');
  // Get the created date from the node and check that it has not changed.
  $this
    ->assertTrue($node->status, 'After cron, the node has been published.');
  $created_after_cron = $node->created;
  $this
    ->assertEqual($created, $created_after_cron, 'The node creation date is not changed by default.');
  // Set option to change the created date to match the publish_on date.
  variable_set('scheduler_publish_touch_page', TRUE);
  // Schedule the node again and run cron.
  $node = $this
    ->schedule($node, 'publish');
  // Check that the created date has changed to match the publish_on date.
  $created_after_cron = $node->created;
  $this
    ->assertEqual(strtotime('-1 day', REQUEST_TIME), $created_after_cron, "With 'touch' option set, the node creation date is changed to match the publishing date.");
}