You are here

function ModuleGrantsViewOpTestCase::testViewOpWithModuleGrantsOnAndViewAll in Module Grants 7

File

./module_grants.test, line 467

Class

ModuleGrantsViewOpTestCase

Code

function testViewOpWithModuleGrantsOnAndViewAll() {
  $this
    ->pass('Test view operations with module grants on, and view all enabled.');
  _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_OR_modules', FALSE);
  variable_set('node_access_test_private', FALSE);

  // first test basic node access with the node_access_test modules
  parent::assetNodeViewAccess(array(
    'Test node 1' => true,
    'Test node 2' => true,
    'Test node 3' => true,
  ), array(
    'node test view',
    'view all pets',
    'view all color',
    'view all number',
  ));

  // now test individual animal/color/number
  parent::assetNodeViewAccess(array(
    'Test node cat' => false,
    'Test node dog' => true,
    'Test node fish' => false,
    'Test node cow' => true,
    'Test node horse' => false,
  ), array(
    'dog',
    'cow',
    'node test view',
    'view all color',
    'view all number',
  ));
  parent::assetNodeViewAccess(array(
    'Test node blue' => true,
    'Test node green' => false,
    'Test node red' => false,
  ), array(
    'blue',
    'node test view',
    'view all pets',
    'view all number',
  ));
  parent::assetNodeViewAccess(array(
    'Test node one' => false,
    'Test node two' => false,
    'Test node three' => false,
  ), array(
    'node test view',
    'view all pets',
    'view all color',
  ));

  // now test combinations
  parent::assetNodeViewAccess(array(
    'Test node cat' => false,
    'Test node dog' => false,
    'Test node fish' => false,
    'Test node cow' => false,
    'Test node horse' => false,
    'Test node blue' => false,
    'Test node green' => false,
    'Test node red' => false,
    'Test node one' => false,
    'Test node two' => false,
    'Test node three' => false,
  ), array(
    'dog',
    'blue',
    'three',
    'node test view',
  ));
  parent::assetNodeViewAccess(array(
    'Test node cat blue' => false,
    'Test node dog green' => false,
    'Test node fish red' => false,
    'Test node cow one' => false,
    'Test node horse two' => false,
    'Test node cat three' => false,
    'Test node dog blue' => false,
    'Test node dog three' => false,
    'Test node blue three' => false,
  ), array(
    'dog',
    'blue',
    'three',
    'node test view',
  ));
  parent::assetNodeViewAccess(array(
    'Test node cat blue one' => false,
    'Test node dog green two' => false,
    'Test node fish red three' => false,
    'Test node cat green one' => false,
    'Test node fish red two' => false,
    'Test node dog blue three' => true,
  ), array(
    'dog',
    'blue',
    'three',
    'node test view',
  ));
}