From ca265ce5eda56177cdf94547866d88387819291b Mon Sep 17 00:00:00 2001 From: Jimmy Puckett Date: Sat, 13 Apr 2024 19:57:53 -0400 Subject: [PATCH] Verify that default decay times are able to be chagned --- tests/Cache/LimitTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Cache/LimitTest.php b/tests/Cache/LimitTest.php index 165ab7799001..a3b1874b85ef 100644 --- a/tests/Cache/LimitTest.php +++ b/tests/Cache/LimitTest.php @@ -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); @@ -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);