public function OpenAtriumAccessAllTestCase::testModuleEnableAndInitialize in Open Atrium Core 7.2
File
- modules/
oa_access/ tests/ oa_access.test, line 812 - Functional tests for the Open Atrium Access module.
Class
- OpenAtriumAccessAllTestCase
- Functional tests for permissions that default to 'All' for the Open Atrium Access module.
Code
public function testModuleEnableAndInitialize() {
// First, make sure we don't have access.
$this
->assertEqual($this
->getGroupPermissions('oa_access_test_all', array(
0,
)), array(
0 => array(),
));
// Then we enable the oa_access_test_all module and check again.
module_enable(array(
'oa_access_test_all',
));
$this
->assertEqual($this
->getGroupPermissions('oa_access_test_all', array(
0,
)), array(
0 => array(
'oa_access_test_all' => array(
'permission that defaults to all for oa_access_test_all',
),
),
));
// Check that only the single permission is defined.
$perms = array(
'permission that defaults to all for oa_access_test_all' => array(
'title' => t('A permission that defaults to the "All" option'),
'description' => t('Used to test the functionality to default to the "All" option'),
'type' => OA_ACCESS_DEFAULT_PERMISSION | OA_ACCESS_DEFAULT_OPTION_ALL,
'module' => 'oa_access_test_all',
'combine' => OA_ACCESS_COMBINE_UNION,
),
);
$this
->assertEqual($this
->getPermissions('oa_access_test_all'), $perms);
// Now, we want to add a new permission and test that it's available.
variable_set('oa_access_test_all_initialize_permissions', TRUE);
$perms['a permission for oa_access_test_all that is added after install'] = array(
'title' => t('Some fickle permission'),
'description' => t('A permission for oa_access_test that is only conditionally available'),
'type' => OA_ACCESS_DEFAULT_PERMISSION | OA_ACCESS_DEFAULT_OPTION_ALL,
'module' => 'oa_access_test_all',
'combine' => OA_ACCESS_COMBINE_UNION,
);
$this
->assertEqual($this
->getPermissions('oa_access_test_all', TRUE), $perms);
// Next, we initialize it and check that the 'All' group has it.
oa_access_initialize_permissions('a permission for oa_access_test_all that is added after install');
$this
->assertEqual($this
->getGroupPermissions('oa_access_test_all', array(
0,
)), array(
0 => array(
'oa_access_test_all' => array(
'a permission for oa_access_test_all that is added after install',
'permission that defaults to all for oa_access_test_all',
),
),
));
}