You are here

public function PartyAccessTestCase::testPartyCRUDAccess in Party 8.2

Same name and namespace in other branches
  1. 7 tests/party_access.test \PartyAccessTestCase::testPartyCRUDAccess()

Test CRUD Access on Party Entities.

@todo: I guess we should check that the pages for each of this options are inaccessible as well.

File

tests/party_access.test, line 46
Access Tests for the Party module.

Class

PartyAccessTestCase
Test Core Party functionality

Code

public function testPartyCRUDAccess() {

  // Create a user with no permissions.
  $user_no_access = $this
    ->drupalCreateUser();

  // Make a user with permission to view parties
  $user = $this
    ->drupalCreateUser(array(
    'view parties',
  ));

  // Assert that the user has access to view the party.
  $this
    ->assertTrue(party_access('view', $this->party, NULL, $user), t('A user with permission view parties can view them.'));

  // Assert that a user with no permissions cannot view the party.
  $this
    ->assertFalse(party_access('view', $this->party, NULL, $user_no_access), t('A user without permission to view parties cannot view them.'));

  // Make a user with permission to edit parties
  $user = $this
    ->drupalCreateUser(array(
    'edit parties',
  ));

  // Assert that the user has access to edit the party.
  $this
    ->assertTrue(party_access('edit', $this->party, NULL, $user), t('A user with permission edit parties can edit them.'));

  // Assert that a user with no permissions cannot edit the party.
  $this
    ->assertFalse(party_access('edit', $this->party, NULL, $user_no_access), t('A user without permission to edit parties cannot edit them.'));

  // Make a user with permission to delete parties
  $user = $this
    ->drupalCreateUser(array(
    'delete parties',
  ));

  // Assert that the user has access to delete the party.
  $this
    ->assertTrue(party_access('delete', $this->party, NULL, $user), t('A user with permission delete parties can delete them.'));

  // Assert that a user with no permissions cannot delete the party.
  $this
    ->assertFalse(party_access('delete', $this->party, NULL, $user_no_access), t('A user without permission to delete parties cannot delete them.'));
}