public function RestfulRateLimitTestCase::testGlobalLimits in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulRateLimitTestCase.test \RestfulRateLimitTestCase::testGlobalLimits()
Tests global rate limits.
File
- tests/
RestfulRateLimitTestCase.test, line 37 - Contains RestfulRateLimitTestCase.
Class
- RestfulRateLimitTestCase
- @file Contains RestfulRateLimitTestCase.
Code
public function testGlobalLimits() {
// Test the global limit.
variable_set('restful_global_rate_limit', 1);
// P3D for 3 days period. See
// http://php.net/manual/en/class.dateinterval.php for more information
// about the interval format.
variable_set('restful_global_rate_period', 'P3D');
$account = $this
->drupalCreateUser();
$this
->roleExecute($account, 1, array(
'articles',
1,
0,
));
// Test invalid 'restful_global_rate_period' format.
try {
variable_set('restful_global_rate_period', 'fail');
$this
->roleExecute($account, 1, array(
'articles',
1,
0,
));
$this
->fail('Invalid \\DateInterval format in restful_global_rate_period did not raise an error');
} catch (Exception $e) {
$this
->pass('Invalid \\DateInterval format in restful_global_rate_period raises an error');
}
}