Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaposa committed Mar 22, 2020
1 parent 2e36b42 commit 671712b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/RateLimiterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,23 @@ public function it_silently_returns_correct_status_when_limit_is_exceeded(): voi
/**
* @test
*/
public function it_silently_tracks_number_of_remaining_attempts(): void
public function it_silently_tracks_rate_limit_status_information(): void
{
$rateLimiter = $this->getRateLimiter();

if (!$rateLimiter instanceof SilentRateLimiter) {
$this->markTestSkipped('RateLimiter not capable of silent limiting');
}

$status = $rateLimiter->limitSilently('test', Rate::perMinute(10));
$identifier = 'test';
$rate = Rate::perMinute(10);

$status = $rateLimiter->limitSilently($identifier, $rate);

$this->assertSame($identifier, $status->getIdentifier());
$this->assertFalse($status->limitExceeded());
$this->assertEquals(9, $status->getRemainingAttempts());
$this->assertSame($rate->getOperations(), $status->getLimit());
$this->assertSame(9, $status->getRemainingAttempts());
}

/**
Expand Down

0 comments on commit 671712b

Please sign in to comment.