forked from webhooksite/webhook.site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RequestControllerTest.php
68 lines (54 loc) · 1.73 KB
/
RequestControllerTest.php
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
59
60
61
62
63
64
65
66
67
68
<?php
class RequestControllerTest extends TestCase
{
public function testPagination()
{
// Prevent throttling
$this->withoutMiddleware();
$number = 175;
$tokenId = $this->json('POST', 'token')->json()['uuid'];
for ($i = 0; $i < $number; $i++) {
$this->call('GET', $tokenId);
}
$requests = $this->json('GET', "token/$tokenId/requests?per_page=40&page=1");
$requests->assertJson([
'total' => $number,
'per_page' => 40,
'current_page' => 1,
'is_last_page' => false,
'from' => 1,
'to' => 40,
]);
$requests = $this->json('GET', "token/$tokenId/requests?per_page=40&page=2");
$requests->assertJson([
'current_page' => 2,
'is_last_page' => false,
'from' => 41,
'to' => 80,
]);
$requests = $this->json('GET', "token/$tokenId/requests?per_page=40&page=3");
$requests->assertJson([
'current_page' => 3,
'is_last_page' => false,
'from' => 81,
'to' => 120,
]);
$requests = $this->json('GET', "token/$tokenId/requests?per_page=40&page=5");
$requests->assertJson([
'current_page' => 5,
'is_last_page' => true,
'from' => 161,
'to' => 175,
]);
$requests = $this->json('GET', "token/$tokenId/requests?per_page=40&page=6");
$requests->assertExactJson([
'data' => [],
'total' => $number,
'per_page' => 40,
'current_page' => 6,
'is_last_page' => true,
'from' => 201,
'to' => 175,
]);
}
}