FloodTest.php in Service Container 7
File
lib/Drupal/service_container/Tests/FloodTest.php
View source
<?php
namespace Drupal\service_container\Tests;
class FloodTest extends ServiceContainerIntegrationTestBase {
protected $eventName;
public static function getInfo() {
return array(
'name' => 'Flood control mechanism',
'description' => 'Functional tests for the flood control mechanism',
'group' => 'service_container',
);
}
public function testFlood() {
$threshold = 1;
$window_expired = -1;
$name = 'flood_test';
\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));
\Drupal::service('flood')
->register($name);
$this
->assertFalse(\Drupal::service('flood')
->isAllowed($name, $threshold));
$this
->cronRun();
$this
->assertFalse(\Drupal::service('flood')
->isAllowed($name, $threshold));
}
}