You are here

function PublishContentWebCaseTest::testNoPermissionByOwner in Publish Content 6

Same name and namespace in other branches
  1. 5.2 tests/publishcontent.test \PublishContentWebCaseTest::testNoPermissionByOwner()

Test the access for the owner of a node without the permission to publish or unpublish.

@note: node's owner can see it even if unpublished by default in Drupal

File

tests/publishcontent.test, line 121
Unit tests for Publish Content module. prerequesite: make sure that 'authenticated user' does not have any access like 'publish [content type] content' or 'unpublish [content type] content'

Class

PublishContentWebCaseTest
@file Unit tests for Publish Content module. prerequesite: make sure that 'authenticated user' does not have any access like 'publish [content type] content' or 'unpublish [content type] content'

Code

function testNoPermissionByOwner() {

  // Prepare a user to do the stuff
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->drupalLogin($web_user);
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'uid' => $web_user->uid,
    'status' => 1,
  ));
  $this
    ->assert_current_user_cannot_publish_node($node);
  $this
    ->assert_current_user_cannot_unpublish_node($node);
  $this
    ->set_node_status($node, 0);
  $this
    ->assert_access_node($node, 'node MUST BE viewable if unpublished');
}