public function PublicationDateTestCase::testActionSavingSetDate in Publication Date 7.2
Same name and namespace in other branches
- 7 tests/publication_date.test \PublicationDateTestCase::testActionSavingSetDate()
Test that it cares about setting the published_at field.
This is useful for people using 'migrate' etc.
File
- tests/
publication_date.test, line 165 - Publication Date module tests.
Class
- PublicationDateTestCase
- Test publication date functionality.
Code
public function testActionSavingSetDate() {
$node = $this
->drupalCreateNode(array(
'status' => 0,
));
$unpublished_node = node_load($node->nid);
$this
->assertTrue(empty($unpublished_node->published_at), 'Published date is initially empty');
// Now publish this with our custom time...
$unpublished_node->status = 1;
$static_time = 12345678;
$unpublished_node->published_at = $static_time;
node_save($unpublished_node);
$published_node = node_load($node->nid);
// ...and see if it comes back with it correctly.
$this
->assertTrue(is_numeric($published_node->published_at), 'Published date is integer/numberic once published');
$this
->assertTrue($published_node->published_at == $static_time, 'Published date is set to what we expected');
}