protected function UserProtectBypassWebTest::doCheckBypass in User protect 7
Tests if bypassing a certain protection is respected.
Parameters
string $protection: The type of protection to test bypassing for.
8 calls to UserProtectBypassWebTest::doCheckBypass()
- UserProtectBypassWebTest::testCancelProtectionBypass in tests/
UserProtectBypassWebTest.test - Tests bypassing cancel protection.
- UserProtectBypassWebTest::testEditProtectionBypass in tests/
UserProtectBypassWebTest.test - Tests bypassing edit protection.
- UserProtectBypassWebTest::testMailProtectionBypass in tests/
UserProtectBypassWebTest.test - Tests bypassing mail protection.
- UserProtectBypassWebTest::testNameProtectionBypass in tests/
UserProtectBypassWebTest.test - Tests bypassing name protection.
- UserProtectBypassWebTest::testOpenIdProtectionBypass in tests/
UserProtectBypassWebTest.test - Tests bypassing openid protection.
File
- tests/
UserProtectBypassWebTest.test, line 116 - Contains UserProtectBypassWebTest.
Class
- UserProtectBypassWebTest
- Tests bypassing protection rules.
Code
protected function doCheckBypass($protection) {
// Assert that the operating account may not bypass.
$this
->assertFalse(userprotect_check_bypass($protection, $this->account));
// Clear static cache for userprotect_check_bypass() function.
drupal_static_reset('userprotect_check_bypass');
drupal_static_reset('userprotect_check_bypass_defaults');
// Now, create the bypass rule.
$this
->createBypassRule($this->account->uid, array(
$protection => 1,
));
// Assert that the operating account may bypass now.
$this
->assertTrue(userprotect_check_bypass($protection, $this->account));
// Remove bypass rule.
db_delete('userprotect')
->condition('uid', $this->account->uid)
->condition('up_type', 'admin')
->execute();
// Clear static cache for userprotect_check_bypass() function again.
drupal_static_reset('userprotect_check_bypass');
drupal_static_reset('userprotect_check_bypass_defaults');
// Assert that the operating account may not bypass anymore.
$this
->assertFalse(userprotect_check_bypass($protection, $this->account));
// Set the global bypass rule.
$protections = array(
$protection => 1,
) + array(
'up_name' => 0,
'up_mail' => 0,
'up_pass' => 0,
'up_status' => 0,
'up_roles' => 0,
'up_openid' => 0,
'up_cancel' => 0,
'up_edit' => 0,
);
variable_set('userprotect_administrator_bypass_defaults', $protections);
// Clear static cache for userprotect_check_bypass() function again.
drupal_static_reset('userprotect_check_bypass');
drupal_static_reset('userprotect_check_bypass_defaults');
// Assert that the operating account may bypass again.
$this
->assertTrue(userprotect_check_bypass($protection, $this->account));
}