forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per-second rate limiting (laravel#48498)
- Loading branch information
1 parent
6c7f670
commit 800e264
Showing
14 changed files
with
472 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Cache; | ||
|
||
use Illuminate\Cache\RateLimiting\GlobalLimit; | ||
use Illuminate\Cache\RateLimiting\Limit; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LimitTest extends TestCase | ||
{ | ||
public function testConstructors() | ||
{ | ||
$limit = new Limit('', 3, 1); | ||
$this->assertSame(1, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = Limit::perSecond(3); | ||
$this->assertSame(1, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = Limit::perMinute(3); | ||
$this->assertSame(60, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = Limit::perMinutes(2, 3); | ||
$this->assertSame(120, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = Limit::perHour(3); | ||
$this->assertSame(3600, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = Limit::perDay(3); | ||
$this->assertSame(86400, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
|
||
$limit = new GlobalLimit(3); | ||
$this->assertSame(60, $limit->decaySeconds); | ||
$this->assertSame(3, $limit->maxAttempts); | ||
} | ||
} |
Oops, something went wrong.