You are here

public function PublishContentWebTestBase::testBasicPublishCallback in Publish Content 7

Test basic publish ability using the publishcontent_test module.

File

tests/publishcontent.test, line 394
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 testBasicPublishCallback() {
  $type = 'page';
  $this
    ->enablePublishContentForContentType(array(
    $type,
    'article',
  ));
  $web_user_1 = $this
    ->drupalCreateUser(array(
    'access content',
    'publish any content',
  ));
  $web_user_2 = $this
    ->drupalCreateUser(array(
    'access content',
    'unpublish any content',
  ));
  $web_user_3 = $this
    ->drupalCreateUser(array(
    'access content',
    'publish any content',
    'unpublish any content',
  ));
  $web_user_4 = $this
    ->drupalCreateUser(array(
    'access content',
    'publish any ' . $type . ' content',
  ));
  $web_user_5 = $this
    ->drupalCreateUser(array(
    'access content',
    'unpublish any ' . $type . ' content',
  ));
  $web_user_6 = $this
    ->drupalCreateUser(array(
    'access content',
    'publish any ' . $type . ' content',
    'unpublish any ' . $type . ' content',
  ));
  $web_user_7 = $this
    ->drupalCreateUser(array(
    'access content',
    'publish any article content',
    'unpublish any article content',
  ));
  $node = $this
    ->drupalCreateNode(array(
    'type' => $type,
    'uid' => 1,
    'status' => 0,
  ));
  $this
    ->drupalLogin($web_user_1);
  $this
    ->assertCanPublishFromLinksPage($node, 'Someone with publish any content can publish page node');
  $this
    ->assertCannotUnpublishFromLinksPage($node, 'Someone with publish any content cannot unpublish page node');
  $this
    ->drupalLogin($web_user_2);
  $this
    ->assertCannotPublishFromLinksPage($node, 'Someone with unpublish any content cannot publish page node');
  $this
    ->assertCanUnpublishFromLinksPage($node, 'Someone with unpublish any content can unpublish page node');
  $this
    ->drupalLogin($web_user_3);
  $this
    ->assertCanPublishFromLinksPage($node, 'Someone with publish and unpublish any content can publish page node');
  $this
    ->assertCanUnpublishFromLinksPage($node, 'Someone with publish and unpublish any content can unpublish page node');
  $this
    ->drupalLogin($web_user_4);
  $this
    ->assertCanPublishFromLinksPage($node, 'Someone with publish any page nodes can publish a page node');
  $this
    ->assertCannotUnpublishFromLinksPage($node, 'Someone with publish any page nodes cannot unpublish page node');
  $this
    ->drupalLogin($web_user_5);
  $this
    ->assertCannotPublishFromLinksPage($node, 'Someone with unpublish any page node cannot publish a page node');
  $this
    ->assertCanUnpublishFromLinksPage($node, 'Someone with unpublish any page node can unpublish a page node');
  $this
    ->drupalLogin($web_user_6);
  $this
    ->assertCanPublishFromLinksPage($node, 'Someone with publish and unpublish any page node can publish a page node');
  $this
    ->assertCanUnpublishFromLinksPage($node, 'Someone with publish and unpublish any page node can unpublish a page node');
  $this
    ->drupalLogin($web_user_7);
  $this
    ->assertCannotPublishFromLinksPage($node, 'Someone with publish any article content cannot publish page content');
  $this
    ->assertCannotUnpublishFromLinksPage($node, 'Someone with unpublish any article content cannot unpublish page content');
}