public function PublishContentWebTestBase::assertCurrentUserCannotPublish in Publish Content 7
Check the current user session forbids publish of a given node.
Parameters
node $node: The node object to test against.
4 calls to PublishContentWebTestBase::assertCurrentUserCannotPublish()
- 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::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 87 - 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 assertCurrentUserCannotPublish($node) {
$status = $node->status;
$username = $this->loggedInUser->name;
$this
->setNodeStatus($node, 1, 'Start test with a published node');
$this
->assertNodeOperationAccess($node->nid, 'publish', 403, $username . ' cannot publish 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, 'publish', 403, $username . ' cannot publish the unpublished node');
$this
->assertNodeStatus($node->nid, 0, 'node should be still unpublished');
$this
->setNodeStatus($node, $status, 'Reset the nodes status');
}