Пример #1
0
 /**
  * Test flood control mechanism clean-up.
  */
 public function testCleanUp()
 {
     $threshold = 1;
     $window_expired = -1;
     $name = 'flood_test_cleanup';
     // Register expired event.
     $flood = \Drupal::flood();
     $flood->register($name, $window_expired);
     // Verify event is not allowed.
     $this->assertFalse($flood->isAllowed($name, $threshold));
     // Run cron and verify event is now allowed.
     $this->cronRun();
     $this->assertTrue($flood->isAllowed($name, $threshold));
     // Register unexpired event.
     $flood->register($name);
     // Verify event is not allowed.
     $this->assertFalse($flood->isAllowed($name, $threshold));
     // Run cron and verify event is still not allowed.
     $this->cronRun();
     $this->assertFalse($flood->isAllowed($name, $threshold));
 }
Пример #2
0
 /**
  * Tests the flood() method.
  *
  * @covers ::flood
  */
 public function testFlood()
 {
     $this->setMockContainerService('flood');
     $this->assertNotNull(\Drupal::flood());
 }