public function PublishContentWebTestBase::assertCurrentUserCannotUnpublish in Publish Content 7
Check the current user session cannot unpublish a given node.
Parameters
node $node: The node object to test against.
4 calls to PublishContentWebTestBase::assertCurrentUserCannotUnpublish()
- PublishContentWebTestBase::testNoPermissionAndNotOwner in tests/
publishcontent.test - Check publishcontent module does not interfere with the normal Drupal.
- PublishContentWebTestBase::testNoPublishPermissionByOwner in tests/
publishcontent.test - Check no publish permission by node owner.
- PublishContentWebTestBase::testPublishNotUnpublish in tests/
publishcontent.test - Test the combination of publish but not unpublish permissions.
- PublishContentWebTestBase::testPublishUnpublish in tests/
publishcontent.test - Test the combination of both publish and unpublish.
File
- tests/
publishcontent.test, line 106 - 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 assertCurrentUserCannotUnpublish($node) {
$status = $node->status;
$username = $this->loggedInUser->name;
$this
->setNodeStatus($node, 1, 'Start test with a published node');
$this
->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot unpublish the published node');
$this
->assertNodeStatus($node->nid, 1, 'node should be still published');
$this
->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the published node');
$this
->setNodeStatus($node, 0);
$this
->assertNodeOperationAccess($node->nid, 'unpublish', 403, $username . ' cannot unpublish an unpublished node');
$this
->assertNodeStatus($node->nid, 0, 'node should be still unpublished');
$this
->setNodeStatus($node, $status, 'Reset the nodes status');
}