You are here

function ModuleGrantsEntityTestCase::testNodeViewAllAccess in Module Grants 7

File

module_grants_entity/module_grants_entity.test, line 17

Class

ModuleGrantsEntityTestCase

Code

function testNodeViewAllAccess() {
  $node = $this
    ->drupalCreateNode(array(
    'title' => "Test node dog blue three",
    'type' => 'article',
  ));
  variable_set('module_grants_lenient', true);
  $this
    ->assertEntityViewAllAccess(array(), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
    'blue',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
    'blue',
    'three',
  ), false);
  variable_set('module_grants_lenient', false);
  $this
    ->assertEntityViewAllAccess(array(), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
    'blue',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'dog',
    'blue',
    'three',
  ), false);
  _module_grants_test_add_view_all(module_grants_test_animal_get_grants(), 1000);
  _module_grants_test_add_view_all(module_grants_test_color_get_grants(), 1001);
  _module_grants_test_add_view_all(module_grants_test_number_get_grants(), 1002);
  variable_set('module_grants_lenient', true);
  $this
    ->assertEntityViewAllAccess(array(), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
    'view all color',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
    'view all color',
    'view all number',
  ), true);
  variable_set('module_grants_lenient', false);
  $this
    ->assertEntityViewAllAccess(array(), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
    'view all color',
  ), false);
  $this
    ->assertEntityViewAllAccess(array(
    'view all pets',
    'view all color',
    'view all number',
  ), true);
}