function RegistrationAPITestCase::testHookAccess in Entity Registration 7.2
Same name and namespace in other branches
- 8.2 tests/registration.test \RegistrationAPITestCase::testHookAccess()
- 7 tests/registration.test \RegistrationAPITestCase::testHookAccess()
Test hook_registration_access().
File
- tests/
registration.test, line 583 - Tests for the Registration module
Class
Code
function testHookAccess() {
$account = $this
->drupalCreateUser();
$crud = array(
'create',
'view',
'update',
'delete',
);
$registration_values = array(
'registrant_id' => $account->uid,
);
// Test hook.
$registration = $this
->createRegistration($registration_values);
$random = $this
->randomString();
$registration->hook_registration_access = $random;
$this
->assertEqual($random, module_invoke('registration_test_api', 'registration_access', 'view', $registration, $account), t('Manually invoke hook_registration_access()'), 'Registration');
// Default access (none).
foreach ($crud as $op) {
$registration = $this
->createRegistration();
$this
->assertFalse(entity_access($op, 'registration', $registration, $account), t('User cannot @op registration.', array(
'@op' => $op,
)), 'Registration');
}
// Force allow access.
foreach ($crud as $op) {
$registration = $this
->createRegistration($registration_values);
$registration->hook_registration_access = TRUE;
$this
->assertTrue(entity_access($op, 'registration', $registration, $account), t('User can @op registration.', array(
'@op' => $op,
)), 'Registration');
}
}