class FloodTest 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
Hierarchy
- class \Drupal\service_container\Tests\ServiceContainerIntegrationTestBase extends \Drupal\service_container\Tests\DrupalWebTestCase
- class \Drupal\service_container\Tests\FloodTest
Expanded class hierarchy of FloodTest
File
- lib/
Drupal/ service_container/ Tests/ FloodTest.php, line 10 - Contains \Drupal\service_container\Tests\FloodTest.
Namespace
Drupal\service_container\TestsView source
class FloodTest extends ServiceContainerIntegrationTestBase {
/**
* A random name for an event.
*
* @var string
*/
protected $eventName;
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Flood control mechanism',
'description' => 'Functional tests for the flood control mechanism',
'group' => 'service_container',
);
}
/**
* The the flood mechanisms.
*/
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));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FloodTest:: |
protected | property | A random name for an event. | |
FloodTest:: |
public static | function | ||
FloodTest:: |
public | function | The the flood mechanisms. | |
ServiceContainerIntegrationTestBase:: |
protected | property | The dependency injection container usable in the test. | |
ServiceContainerIntegrationTestBase:: |
protected | property | The profile to install as a basis for testing. | 1 |
ServiceContainerIntegrationTestBase:: |
protected | function | 5 |