function WorkbenchModerationTransitionTestCase::testTransitionFromNodeForm in Workbench Moderation 7.3
File
- tests/
workbench_moderation.transition.test, line 41 - Tests for node transition hooks with workbench_moderation.module.
Class
- WorkbenchModerationTransitionTestCase
- @file Tests for node transition hooks with workbench_moderation.module.
Code
function testTransitionFromNodeForm() {
// Create a new node and publish it immediately.
$body_name = 'body[' . LANGUAGE_NONE . '][0]';
$edit = array(
'title' => $this
->randomName(),
"{$body_name}[value]" => $this
->randomString(128),
"{$body_name}[format]" => filter_default_format(),
'workbench_moderation_state_new' => workbench_moderation_state_published(),
);
$this
->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
// Test the published state transition.
$expected = array(
'nid' => 1,
'vid' => 1,
'title' => $edit['title'],
'previous_state' => 'draft',
'new_state' => 'published',
'status' => 1,
);
$this
->assertTransition($expected);
// Create a new draft of the published node.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$edit = array(
'title' => 'Draft node revision1',
);
$this
->drupalPost("node/{$node->nid}/edit", $edit, t('Save'));
$expected = array(
'nid' => 1,
'vid' => 2,
'title' => $edit['title'],
'previous_state' => 'published',
'new_state' => 'draft',
'status' => 0,
);
$this
->assertTransition($expected);
// Moderate to needs review and check transition.
$this
->drupalGet("node/1/moderation/2/change-state/needs_review", array(
'query' => array(
'token' => $this
->drupalGetToken("1:2:needs_review"),
),
));
$expected = array(
'nid' => 1,
'vid' => 2,
'title' => $edit['title'],
'previous_state' => 'draft',
'new_state' => 'needs_review',
'status' => 0,
);
$this
->assertTransition($expected);
// Publish the revision and check transition.
$this
->drupalGet("node/1/moderation/2/change-state/published", array(
'query' => array(
'token' => $this
->drupalGetToken("1:2:published"),
),
));
$expected = array(
'nid' => 1,
'vid' => 2,
'title' => $edit['title'],
'previous_state' => 'needs_review',
'new_state' => 'published',
'status' => 1,
);
$this
->assertTransition($expected);
// Create a new node and make sure it is unpublished.
$body_name = 'body[' . LANGUAGE_NONE . '][0]';
$edit = array(
'title' => $this
->randomName(),
"{$body_name}[value]" => $this
->randomString(128),
"{$body_name}[format]" => filter_default_format(),
);
$this
->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));
// Get the new node.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$expected = array(
'nid' => $node->nid,
'vid' => $node->vid,
'title' => $edit['title'],
'previous_state' => 'draft',
'new_state' => 'draft',
'status' => 0,
);
$this
->assertTransition($expected);
}