You are here

public function AckNodeAccessTest::setUp in Access Control Kit 7

Overrides DrupalWebTestCase::setUp().

Overrides DrupalWebTestCase::setUp

File

ack_node/ack_node.test, line 62
Tests for the ACK node module.

Class

AckNodeAccessTest
Tests the node access functions.

Code

public function setUp() {
  parent::setUp(array(
    'ack_node',
  ));

  // Create and log in our admin user.
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer access schemes',
    'administer access grants',
    'edit any article content',
  ));
  $this
    ->drupalLogin($this->adminUser);

  // Create the test roles.
  $rid = $this
    ->drupalCreateRole(array(
    'ack create article content',
    'ack edit own article content',
    'ack delete own article content',
  ));
  $this->ackRoleOwn = user_role_load($rid);
  $rid = $this
    ->drupalCreateRole(array(
    'ack edit any article content',
    'ack delete any article content',
  ));
  $this->ackRoleAny = user_role_load($rid);

  // Create a user account for use in access grants.
  $this->ackUser = $this
    ->drupalCreateUser(array(
    'access content',
  ));

  // Add the user to the test roles.
  db_insert('users_roles')
    ->fields(array(
    'uid' => $this->ackUser->uid,
    'rid' => $this->ackRoleOwn->rid,
  ))
    ->execute();
  db_insert('users_roles')
    ->fields(array(
    'uid' => $this->ackUser->uid,
    'rid' => $this->ackRoleAny->rid,
  ))
    ->execute();
  $pass_raw = $this->ackUser->pass_raw;
  $this->ackUser = user_load($this->ackUser->uid, TRUE);
  $this->ackUser->pass_raw = $pass_raw;

  // Create the test node.
  $this->node = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
}