public function FloodTest::testMemoryBackendThreshold in Drupal 10
Tests memory backend records events to the nearest microsecond.
File
- core/modules/ system/ tests/ src/ Kernel/ System/ FloodTest.php, line 80 
Class
- FloodTest
- Functional tests for the flood control mechanism.
Namespace
Drupal\Tests\system\Kernel\SystemCode
public function testMemoryBackendThreshold() {
  $request_stack = \Drupal::service('request_stack');
  $flood = new MemoryBackend($request_stack);
  $flood
    ->register('new event');
  $this
    ->assertTrue($flood
    ->isAllowed('new event', '2'));
  $flood
    ->register('new event');
  $this
    ->assertFalse($flood
    ->isAllowed('new event', '2'));
}