private function WorkbenchSchedulerNodeScheduleTestCase::createScheduledNode in Workbench Scheduler 7
Same name and namespace in other branches
- 7.2 tests/workbench_scheduler.test \WorkbenchSchedulerNodeScheduleTestCase::createScheduledNode()
Create Node With Schedule.
Parameters
$sid:
$time_start:
$time_end:
Return value
mixed
1 call to WorkbenchSchedulerNodeScheduleTestCase::createScheduledNode()
- WorkbenchSchedulerNodeScheduleTestCase::testNodeSchedule in tests/
workbench_scheduler.test - Test Node Schedule.
File
- tests/
workbench_scheduler.test, line 119 - Tests for workbench_scheduler.module.
Class
- WorkbenchSchedulerNodeScheduleTestCase
- Assign node to schedule.
Code
private function createScheduledNode($sid, $time_start, $time_end) {
// Create node to edit.
$langcode = LANGUAGE_NONE;
$body_key = "body[{$langcode}][0][value]";
$edit = array();
$edit['title'] = $this
->randomName(8);
$edit[$body_key] = $this
->randomName(16);
$edit['workbench_scheduler_sid'] = $sid;
$edit['workbench_scheduler_start_date[date]'] = date('Y-m-d', $time_start);
$edit['workbench_scheduler_start_date[time]'] = date('H:i', $time_start);
$edit['workbench_scheduler_end_date[date]'] = date('Y-m-d', $time_end);
$edit['workbench_scheduler_end_date[time]'] = date('H:i', $time_end);
$this
->drupalPost('node/add/' . $this->content_type, $edit, t('Save'));
// Checking the node.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$this
->assertTrue($node, "Node {$node->title} created");
$result = db_select('workbench_scheduler_nodes', 'wsn')
->fields('wsn')
->condition('wsn.nid', $node->nid, '=')
->condition('wsn.sid', $sid, '=')
->condition('wsn.start_date', $time_start, '=')
->condition('wsn.end_date', $time_end, '=')
->range(0, 1)
->execute()
->rowCount();
$this
->assertTrue($result, "Schedule assigned to node {$node->title}");
return $node;
}