public function NodeViewPermissionsTest::testViewOwn in Node View Permissions 7
Test users with a "view own content" permission.
Ensure that these users can view nodes of this type that they created.
Throws
\Behat\Mink\Exception\ExpectationException
File
- tests/
node_view_permissions.test, line 53
Class
- NodeViewPermissionsTest
- Tests for Node View Permissions.
Code
public function testViewOwn() {
$user1 = $this
->drupalCreateUser(array(
'view own article content',
));
$user2 = $this
->drupalCreateUser(array(
'view own article content',
));
$node = $this
->drupalCreateNode([
'type' => 'article',
'uid' => $user1->uid,
]);
$lookup = [
[
$user1,
self::HTTP_OK,
],
[
$user2,
self::HTTP_FORBIDDEN,
],
];
foreach ($lookup as $i) {
list($user, $expected) = $i;
$this
->drupalLogin($user);
$this
->drupalGet("node/{$node->nid}");
$this
->assertResponse($expected);
}
}