public function WorkbenchModerationTransitionTestCase::testTransitionFromNodeSave in Workbench Moderation 7.3
File
- tests/
workbench_moderation.transition.test, line 166 - Tests for node transition hooks with workbench_moderation.module.
Class
- WorkbenchModerationTransitionTestCase
- @file Tests for node transition hooks with workbench_moderation.module.
Code
public function testTransitionFromNodeSave() {
// Create a brand new unpublished node programmatically.
$edit = array(
'title' => $this
->randomName(),
'type' => $this->content_type,
'status' => NODE_NOT_PUBLISHED,
);
$this->node = $this
->drupalCreateNode($edit);
// Get the new node.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$expected = array(
'nid' => 1,
'vid' => 1,
'title' => $edit['title'],
'previous_state' => 'draft',
'new_state' => 'draft',
'status' => 0,
);
$this
->assertTransition($expected);
$node = $this
->drupalGetNodeByTitle($edit['title']);
$node = node_load($node->nid, NULL, TRUE);
// Update the status external to our processes.
$node->status = 1;
$node->title = 'New title';
node_save($node);
$expected = array(
'nid' => 1,
'vid' => 1,
'title' => $node->title,
'previous_state' => 'draft',
'new_state' => 'published',
'status' => 1,
);
$this
->assertTransition($expected);
// Ensure that multiple saves that do not spawn a new PHP request are
// handled correctly to protect against stale static cache.
$node = $this
->drupalGetNodeByTitle($node->title);
$node = node_load($node->nid, NULL, TRUE);
$node->status = 1;
$node->title = 'Newer title';
node_save($node);
$expected = array(
'nid' => 1,
'vid' => 1,
'title' => $node->title,
'previous_state' => 'published',
'new_state' => 'published',
'status' => 1,
);
$this
->assertTransition($expected);
}