public function PublishContentWebTestBase::assertCurrentUserCanUnpublish in Publish Content 7
Check the current user session can unpublish a node.
Parameters
node $node: The node to test against.
2 calls to PublishContentWebTestBase::assertCurrentUserCanUnpublish()
- PublishContentWebTestBase::testNotPublishUnpublish in tests/
publishcontent.test - Test the combination of unpublish but not publish.
- PublishContentWebTestBase::testPublishUnpublish in tests/
publishcontent.test - Test the combination of both publish and unpublish.
File
- tests/
publishcontent.test, line 144 - Unit tests for Publish Content module.
Class
- PublishContentWebTestBase
- We test to ensure we are not messing up with the default Drupal access for view node i.e. a owner of a node can view it even if unpublished.
Code
public function assertCurrentUserCanUnpublish($node) {
$status = $node->status;
$username = $this->loggedInUser->name;
$this
->setNodeStatus($node, 1, 'Start test with a published node');
$this
->assertNodeOperationAccess($node->nid, 'unpublish', 200, $username . ' can access unpublish callback on a published node');
$this
->assertNodeStatus($node->nid, 0, 'Node should now be unpublished');
$this
->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the unpublished node.');
$this
->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot access the unpublish callback of an unpublished node');
$this
->assertNodeStatus($node->nid, 0, 'Node should still be unpublished');
$this
->setNodeStatus($node, $status, 'Reset the nodes status');
}