You are here

public function NodeViewPermissionsTest::testViewAny in Node View Permissions 7

Test users with a "view any content" permission.

Ensure that these users can view any node of this type, including ones that they did not create.

Throws

\Behat\Mink\Exception\ExpectationException

File

tests/node_view_permissions.test, line 86

Class

NodeViewPermissionsTest
Tests for Node View Permissions.

Code

public function testViewAny() {
  $user1 = $this
    ->drupalCreateUser(array(
    'view any article content',
  ));
  $user2 = $this
    ->drupalCreateUser(array(
    'view any article content',
  ));
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'uid' => $user1->uid,
  ]);
  foreach ([
    $user1,
    $user2,
  ] as $user) {
    $this
      ->drupalLogin($user);
    $this
      ->drupalGet("node/{$node->nid}");
    $this
      ->assertResponse(self::HTTP_OK);
  }
}