You are here

function ModuleGrantsViewOpTestCase::doViewOpTestWithModuleGrantsOff in Module Grants 7

2 calls to ModuleGrantsViewOpTestCase::doViewOpTestWithModuleGrantsOff()
ModuleGrantsViewOpTestCase::testViewOpWithModuleGrantsOff in ./module_grants.test
ModuleGrantsViewOpTestCase::testViewOpWithModuleGrantsOffAndViewAll in ./module_grants.test

File

./module_grants.test, line 284

Class

ModuleGrantsViewOpTestCase

Code

function doViewOpTestWithModuleGrantsOff($enable_view_all) {
  if ($enable_view_all) {
    _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', TRUE);
  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',
  ));

  // 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',
  ));
  parent::assetNodeViewAccess(array(
    'Test node blue' => true,
    'Test node green' => false,
    'Test node red' => false,
  ), array(
    'blue',
  ));
  parent::assetNodeViewAccess(array(
    'Test node one' => false,
    'Test node two' => false,
    'Test node three' => false,
  ), array());

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