public function FloodTest::testFlood in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/service_container/Tests/FloodTest.php \Drupal\service_container\Tests\FloodTest::testFlood()
The the flood mechanisms.
File
- lib/
Drupal/ service_container/ Tests/ FloodTest.php, line 33 - Contains \Drupal\service_container\Tests\FloodTest.
Class
Namespace
Drupal\service_container\TestsCode
public function testFlood() {
$threshold = 1;
$window_expired = -1;
$name = 'flood_test';
// Register expired event.
\Drupal::service('flood')
->register($name, $window_expired);
$this
->assertFalse(\Drupal::service('flood')
->isAllowed($name, $threshold));
$this
->cronRun();
$this
->assertTrue(\Drupal::service('flood')
->isAllowed($name, $threshold));
// Register unexpired event.
\Drupal::service('flood')
->register($name);
$this
->assertFalse(\Drupal::service('flood')
->isAllowed($name, $threshold));
$this
->cronRun();
$this
->assertFalse(\Drupal::service('flood')
->isAllowed($name, $threshold));
}