function WorkbenchModerationDraftTabTestCase::testDraftTab in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 tests/workbench_moderation.test \WorkbenchModerationDraftTabTestCase::testDraftTab()
File
- tests/workbench_moderation.test, line 150
- Tests for workbench_moderation.module.
Class
- WorkbenchModerationDraftTabTestCase
Code
function testDraftTab() {
$body_name = 'body[' . LANGUAGE_NONE . '][0]';
$edit = array(
'title' => $this
->randomName(),
"{$body_name}[value]" => $this
->randomName(128),
"{$body_name}[format]" => filter_default_format(),
);
$this
->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
$node = $this
->drupalGetNodeByTitle($edit['title']);
$this
->assertFalse($node->status, t('New content is unpublished'));
$moderate = array(
'state' => workbench_moderation_state_published(),
);
$this
->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply'));
$node = node_load($node->nid, NULL, TRUE);
$this
->assertTrue($node->status, t('Content is published'));
$edit = array(
'title' => $this
->randomName(10) . '_revision1',
"{$body_name}[value]" => $this
->randomName(128) . '_revision1',
);
$this
->drupalPost("node/{$node->nid}/edit", $edit, t('Save'));
$this
->drupalGet("node/{$node->nid}/draft");
$this
->assertResponse(200, t('Draft tab is accessible'));
$this
->assertText($edit['title']);
$this
->assertText($edit["{$body_name}[value]"]);
$middle_state = current(array_diff(array_keys(workbench_moderation_states()), array(
workbench_moderation_state_none(),
workbench_moderation_state_published(),
)));
$edit = array(
'state' => $middle_state,
);
$this
->drupalPost(NULL, $edit, t('Apply'));
$this
->assertUrl("node/{$node->nid}/draft");
$this
->assertResponse(200);
$edit = array(
'state' => workbench_moderation_state_published(),
);
$this
->drupalPost(NULL, $edit, t('Apply'));
$this
->assertUrl("node/{$node->nid}");
$this
->assertResponse(200);
}