You are here

public function PublishContentWebTestBase::assertCurrentUserCanPublish in Publish Content 7

Check the current user session can publish a given node.

Parameters

node $node: The node object to test against.

2 calls to PublishContentWebTestBase::assertCurrentUserCanPublish()
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 125
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 assertCurrentUserCanPublish($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 access the publish callback for a node which is already published.');
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view the published node');
  $this
    ->setNodeStatus($node, 0);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, $username . ' can view unpublished node');
  $this
    ->assertNodeOperationAccess($node->nid, 'publish', 200, $username . ' can access publish callback on an unpublished node');
  $this
    ->assertNodeStatus($node->nid, 1, 'node should now be published');
  $this
    ->setNodeStatus($node, $status, 'Reset the nodes status');
}