public function SchedulerFunctionalTest::testMetaInformation in Scheduler 7
Tests meta-information on scheduled nodes.
When nodes are scheduled for unpublication, an X-Robots-Tag HTTP header is sent, alerting crawlers about when an item expires and should be removed from search results.
File
- tests/
scheduler.test, line 834 - Scheduler module test case file.
Class
- SchedulerFunctionalTest
- Tests the scheduler interface.
Code
public function testMetaInformation() {
// Log in.
$this
->drupalLogin($this->adminUser);
// Create a published node without scheduling.
$published_node = $this
->drupalCreateNode(array(
'type' => 'page',
'status' => 1,
));
$this
->drupalGet('node/' . $published_node->nid);
// Since we did not set an unpublish date, there should be no X-Robots-Tag
// header on the response.
$this
->assertFalse($this
->drupalGetHeader('X-Robots-Tag'), 'X-Robots-Tag is not present when no unpublish date is set.');
// Set a scheduler unpublish date on the node.
$unpublish_date = strtotime('+1 day', REQUEST_TIME);
$edit = array(
'unpublish_on' => format_date($unpublish_date, 'custom', 'Y-m-d H:i:s'),
);
$this
->drupalPost('node/' . $published_node->nid . '/edit', $edit, t('Save'));
// The node page should now have an X-Robots-Tag header with an
// unavailable_after-directive and RFC850 date- and time-value.
$this
->drupalGet('node/' . $published_node->nid);
$robots_tag = $this
->drupalGetHeader('X-Robots-Tag');
$this
->assertEqual($robots_tag, 'unavailable_after: ' . date(DATE_RFC850, $unpublish_date), 'X-Robots-Tag is present with correct timestamp derived from unpublish_on date.');
}