Skip to content

Commit

Permalink
Verify that default decay times are able to be chagned
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmypuckett committed Apr 13, 2024
1 parent bd3f517 commit ca265ce
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Cache/LimitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ public function testConstructors()
$this->assertSame(1, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perSecond(3, 5);
$this->assertSame(5, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perMinute(3);
$this->assertSame(60, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perMinute(3, 4);
$this->assertSame(240, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perMinutes(2, 3);
$this->assertSame(120, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);
Expand All @@ -30,10 +38,18 @@ public function testConstructors()
$this->assertSame(3600, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perHour(3, 2);
$this->assertSame(7200, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perDay(3);
$this->assertSame(86400, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = Limit::perDay(3, 5);
$this->assertSame(432000, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);

$limit = new GlobalLimit(3);
$this->assertSame(60, $limit->decaySeconds);
$this->assertSame(3, $limit->maxAttempts);
Expand Down

0 comments on commit ca265ce

Please sign in to comment.