-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathRateLimitTest.php
More file actions
58 lines (50 loc) · 1.43 KB
/
Copy pathRateLimitTest.php
File metadata and controls
58 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Noxlogic\RateLimitBundle\Tests\Attribute;
use Noxlogic\RateLimitBundle\Attribute\RateLimit;
use Noxlogic\RateLimitBundle\Tests\TestCase;
class RateLimitTest extends TestCase
{
public function testConstruction(): void
{
$attribute = new RateLimit();
$this->assertEquals(-1, $attribute->limit);
$this->assertEmpty($attribute->methods);
$this->assertEquals(3600, $attribute->period);
}
public function testConstructionWithValues(): void
{
$attribute = new RateLimit(
[],
1234,
1000
);
$this->assertEquals(1234, $attribute->limit);
$this->assertEquals(1000, $attribute->period);
$attribute = new RateLimit(
['POST'],
1234,
1000
);
$this->assertEquals(1234, $attribute->limit);
$this->assertEquals(1000, $attribute->period);
$this->assertEquals(['POST'], $attribute->methods);
}
public function testConstructionWithMethods(): void
{
$attribute = new RateLimit(
['POST', 'GET'],
1234,
1000
);
self::assertCount(2, $attribute->methods);
}
public function testConstructWithStringAsMethods(): void
{
$attribute = new RateLimit(
'POST',
1234,
1000
);
self::assertSame(['POST'], $attribute->methods);
}
}