You are here

public function ApiRateLimitCheckTest::testApiRateLimitCheck in CloudFlare 8

Tests that ApiRateLimitCheck Responds as expected with test purge rates.

@dataProvider apiRateLimitProvider

Parameters

int $api_rate: The currentAPI rate to test.

int $expected_severity: The expected diagnostic severity.

File

modules/cloudflarepurger/tests/src/Unit/ApiRateLimitCheckTest.php, line 28

Class

ApiRateLimitCheckTest
Tests that purge_requirements() passes on our diagnostic checks.

Namespace

Drupal\Tests\cloudflarepurger\Unit

Code

public function testApiRateLimitCheck($api_rate, $expected_severity) {
  $this->drupalState
    ->set(State::API_RATE_COUNT, $api_rate);
  $this->drupalState
    ->set(State::API_RATE_COUNT_START, new \DateTime());
  $api_rate_limit_check = new ApiRateLimitCheck([], '23123', 'this is a definition', $this->cloudflareState, $this->composerDependencyStub);
  $actual_severity = $api_rate_limit_check
    ->run();
  $this
    ->assertEquals($expected_severity, $actual_severity);
}