public function NodeaccesssPublishTestCase::setUp in Nodeaccess 7
Enable the nodeaccess module. Add type grant for pages. Rebuild perms.
Overrides DrupalWebTestCase::setUp
File
- tests/
nodeaccess_publish.test, line 29 - Tests for the nodeaccess module.
Class
- NodeaccesssPublishTestCase
- Tests the functionality of the nodeaccess module.
Code
public function setUp() {
parent::setUp('nodeaccess');
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
'access content',
));
nodeaccess_add_type_grant('page');
// Let's create a sample authenticated user with basic permissions.
$this->basic_user = $this
->drupalCreateUser(array(
'access content',
));
// Let's create a sample author-type user.
$this->author_user = $this
->drupalCreateUser(array(
'access content',
'view own unpublished content',
));
// Let's create a more admin-type user.
$this->admin_user = $this
->drupalCreateUser(array(
'access content',
'bypass node access',
));
// Create a published page node, authored by admin.
$this->published_node = $this
->drupalCreateNode(array(
'type' => 'page',
'uid' => 1,
));
// Create an unpublished page node, authored by admin.
$this->unpublished_node = $this
->drupalCreateNode(array(
'type' => 'page',
'uid' => 1,
'status' => 0,
));
// Create an unpublished page node, authored by author.
$this->authored_node = $this
->drupalCreateNode(array(
'type' => 'page',
'uid' => $this->author_user->uid,
'status' => 0,
));
$this->grant = array(
array(
'gid' => DRUPAL_ANONYMOUS_RID,
'realm' => 'nodeaccess_rid',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
),
array(
'gid' => DRUPAL_AUTHENTICATED_RID,
'realm' => 'nodeaccess_rid',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
),
);
node_access_rebuild();
}