public function WorkbenchModerationExternalNodeUpdateTestCase::testNodeSave in Workbench Moderation 7
Same name and namespace in other branches
- 7.3 tests/external_node_update.test \WorkbenchModerationExternalNodeUpdateTestCase::testNodeSave()
Tests if nodes can be moderated by third party modules.
File
- tests/
external_node_update.test, line 48 - Tests moderation states when nodes are (un)published by other modules.
Class
- WorkbenchModerationExternalNodeUpdateTestCase
- @file Tests moderation states when nodes are (un)published by other modules.
Code
public function testNodeSave() {
// Create a brand new unpublished node programmatically.
$settings = array(
'title' => $this
->randomName(),
'type' => $this->content_type,
'status' => NODE_NOT_PUBLISHED,
);
$this->node = $this
->drupalCreateNode($settings);
// Assert that the node is initially in state draft and not published.
$expected = array(
'state' => 'draft',
);
$this
->assertModerationStatus($expected, 'is_current', 'The moderation status is correct for a newly created node.');
$this
->assertNoPublishedRecord('A newly created node does not have a published entry in the node history table.');
$this
->assertPublicationState(FALSE, 'A newly created node is not published.');
// Resave the node and check that the status doesn't change.
$this
->resaveNode();
$this
->assertModerationStatus($expected, 'is_current', 'The moderation status is correct for a newly created node.');
$this
->assertNoPublishedRecord('A newly created node does not have a published entry in the node history table.');
$this
->assertPublicationState(FALSE, 'A newly created node is not published.');
// Publish the node in an external module and check that the moderation
// state changes accordingly.
$this
->drupalGet('workbench_moderation_test/' . $this->node->nid . '/publish');
$this
->refreshNode();
$expected = array(
'state' => 'published',
);
$this
->assertModerationStatus($expected, 'is_current', 'The moderation state changed to "published" if the node is published externally.');
$this
->assertModerationStatus($expected, 'published', 'A published moderation state record is created when the node is published externally.');
$this
->assertPublicationState(TRUE, 'A node which is published externally is actually published.');
// Resave the node and check that the status doesn't change.
$this
->resaveNode();
$this
->assertModerationStatus($expected, 'is_current', 'The moderation state changed to "published" if the node is published externally.');
$this
->assertModerationStatus($expected, 'published', 'A published moderation state record is created when the node is published externally.');
$this
->assertPublicationState(TRUE, 'A node which is published externally is actually published.');
// Unpublish the node in an external module and check that the moderation
// state changes accordingly.
$this
->drupalGet('workbench_moderation_test/' . $this->node->nid . '/unpublish');
$this
->refreshNode();
$expected = array(
'state' => 'draft',
);
$this
->assertModerationStatus($expected, 'is_current', 'The moderation state changed to "draft" if the node is unpublished externally.');
$this
->assertNoPublishedRecord('The published moderation state record is removed when the node is unpublished externally.');
$this
->assertPublicationState(FALSE, 'A node which is unpublished externally is actually unpublished.');
// Resave the node and check that the status doesn't change.
$this
->resaveNode();
$this
->assertModerationStatus($expected, 'is_current', 'The moderation state changed to "draft" if the node is unpublished externally.');
$this
->assertNoPublishedRecord('The published moderation state record is removed when the node is unpublished externally.');
$this
->assertPublicationState(FALSE, 'A node which is unpublished externally is actually unpublished.');
}