diff --git a/tests/group_node_access.test b/tests/group_node_access.test index f17a857..6870877 100644 --- a/tests/group_node_access.test +++ b/tests/group_node_access.test @@ -187,7 +187,9 @@ class GroupNodeAccessTestCase extends GroupTestHelper { } /** - * Test outsider access on public node created by a group member. + * Test outsider access on public node created by a group member and also + * check that a public unpublished node could be view by the outsider author + * which have node permission 'view own unpublished content'. */ public function _testNodeAccessPublicViewAllow() { @@ -202,14 +204,35 @@ class GroupNodeAccessTestCase extends GroupTestHelper { $this->drupalGet($entity_uri['path'], $entity_uri['options']); $this->assertResponse(200, t('Outsider could access a public node.')); $this->drupalLogout(); + + $account = $this->drupalCreateUser(array('access content', 'view own unpublished content')); + $node = $this->drupalCreateNode(array( + 'type' => $this->nodeType->type, + 'uid' => $account->uid, + 'status' => NODE_NOT_PUBLISHED, + )); + $entity_uri = entity_uri('node', $node); + + $this->drupalLogin($account); + $this->drupalGet($entity_uri['path'], $entity_uri['options']); + $this->assertResponse(200, t('Outsider with "view own unpublished content" could view its own unpublished public node.')); + $this->drupalLogout(); } /** - * Test member access on a private node. + * Test member access on a private node : + * - published by a member of the group + * - not published by a member which have node permission 'view unpublished node' */ public function _testNodeAccessPrivateViewAllow() { - $node = $this->createGroupPrivateNode(); + $account = $this->createGroupMember( + $this->group, + array($this->groupRoleEditorOwn->name), + array('access content', 'view own unpublished content') + ); + + $node = $this->createGroupPrivateNode(array('uid' => $account->uid)); $entity_uri = entity_uri('node', $node); //Check node page with a member. @@ -217,6 +240,14 @@ class GroupNodeAccessTestCase extends GroupTestHelper { $this->drupalGet($entity_uri['path'], $entity_uri['options']); $this->assertResponse(200, t('Member could access a private node.')); $this->drupalLogout(); + + //Unpublished the node and check access for the author + $node->status = NODE_NOT_PUBLISHED; + node_save($node); + $this->drupalLogin($account); + $this->drupalGet($entity_uri['path'], $entity_uri['options']); + $this->assertResponse(200, t('Member with node permission "view own unpublished content" could access its own unpublished private node.')); + $this->drupalLogout(); } /** @@ -227,17 +258,24 @@ class GroupNodeAccessTestCase extends GroupTestHelper { $node = $this->drupalCreateNode(array( 'type' => $this->nodeType->type, + 'status' => NODE_NOT_PUBLISHED, )); $entity_uri = entity_uri('node', $node); - //Remove 'access content' permission from anonymous role temporary. - user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access content')); - if ($this->loggedInUser) { $this->drupalLogout(); } $this->drupalGet($entity_uri['path'], $entity_uri['options']); + $this->assertResponse(403, t('Outsider could not view unpublished public node.')); + + $node->status = NODE_PUBLISHED; + node_save($node); + + //Remove 'access content' permission from anonymous role temporary. + user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access content')); + + $this->drupalGet($entity_uri['path'], $entity_uri['options']); $this->assertResponse(403, t('Outsider without access content node permission could not view a public node.')); //Reset default anonymous role permissions. @@ -246,8 +284,9 @@ class GroupNodeAccessTestCase extends GroupTestHelper { /** * Test outsider access on a private node with : - * - an outsider which have access content permission. + * - an outsider which have access content permission * - a member of an another group + * - a member of the group but node is unpublished */ public function _testNodeAccessPrivateViewDenied() { @@ -267,6 +306,14 @@ class GroupNodeAccessTestCase extends GroupTestHelper { $this->drupalGet($entity_uri['path'], $entity_uri['options']); $this->assertResponse(403, t('Member of an another group could not view private node.')); $this->drupalLogout(); + + //Unpublished the node + $node->status = NODE_NOT_PUBLISHED; + node_save($node); + $this->drupalLogin($this->groupMemberEditorAny); + $this->drupalGet($entity_uri['path'], $entity_uri['options']); + $this->assertResponse(403, t('Member of the group could not view unpublished private node.')); + $this->drupalLogout(); } /**