public function SchedulerApiTestCase::testAllowedPublishing in Scheduler 7
Tests hook_scheduler_allow().
This hook can allow or deny the (un)publication of individual nodes. This test uses a content type 'scheduler_test' which has a checkbox 'Approved for publication by the CEO'. Only if this is checked the node may be published.
@todo Create and update the nodes through the interface so we can check if the correct messages are displayed.
File
- tests/
scheduler_api.test, line 53 - Tests for the Scheduler API.
Class
- SchedulerApiTestCase
- Tests to cover the Scheduler API functions.
Code
public function testAllowedPublishing() {
// Create a node that is not approved for publication. Then simulate a cron
// run, and check that the node is not published.
$node = $this
->createUnapprovedNode();
scheduler_cron();
$this
->assertNodeNotPublished($node->nid, 'An unapproved node is not published after scheduling.');
// Approve the node for publication, simulate a cron run, check that the
// node is now published.
$this
->approveNode($node->nid);
scheduler_cron();
$this
->assertNodePublished($node->nid, 'An approved node is published after scheduling.');
// Turn on immediate publication of nodes with publication dates in the past
// and repeat the tests. It is not needed to simulate cron runs now.
variable_set('scheduler_publish_past_date_scheduler_test', 'publish');
$node = $this
->createUnapprovedNode();
$this
->assertNodeNotPublished($node->nid, 'An unapproved node is not published immediately after saving.');
$this
->approveNode($node->nid);
$this
->assertNodePublished($node->nid, 'An approved node is published immediately after saving.');
}