flood example

$this->assertInstanceOf(QueryAggregateInterface::class, \Drupal::entityQueryAggregate('test_entity', 'OR'));
  }

  /** * Tests the flood() method. * * @covers ::flood */
  public function testFlood() {
    $this->setMockContainerService('flood');
    $this->assertNotNull(\Drupal::flood());
  }

  /** * Tests the moduleHandler() method. * * @covers ::moduleHandler */
  public function testModuleHandler() {
    $this->setMockContainerService('module_handler');
    $this->assertNotNull(\Drupal::moduleHandler());
  }

  
protected static $modules = ['system'];

  /** * Tests flood control mechanism clean-up. */
  public function testCleanUp() {
    $threshold = 1;
    $window_expired = -1;
    $name = 'flood_test_cleanup';
    $cron = $this->container->get('cron');

    $flood = \Drupal::flood();
    $this->assertTrue($flood->isAllowed($name$threshold));
    // Register expired event.     $flood->register($name$window_expired);
    // Verify event is not allowed.     $this->assertFalse($flood->isAllowed($name$threshold));
    // Run cron and verify event is now allowed.     $cron->run();
    $this->assertTrue($flood->isAllowed($name$threshold));

    // Register unexpired event.     $flood->register($name);
    
Home | Imprint | This part of the site doesn't use cookies.