Repository navigation
Expand file tree
/
Copy pathRateLimitTest.php
More file actions
102 lines (90 loc) · 2.18 KB
/
Copy pathRateLimitTest.php
File metadata and controls
102 lines (90 loc) · 2.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace Github\Tests\Api;
use Github\Api\RateLimit;
class RateLimitTest extends TestCase
{
/**
* Used for common assertions in each test.
*
* @var array
*/
protected $expectedArray = [
'resources' => [
'core' => [
'limit' => 5000,
'remaining' => 4999,
'reset' => 1372700873,
],
'search' => [
'limit' => 30,
'remaining' => 18,
'reset' => 1372697452,
],
'graphql' => [
'limit' => 5000,
'remaining' => 4030,
'reset' => 1372697452,
],
],
];
/**
* @var RateLimit
*/
protected $api;
/**
* Used to construct common expectations for the API input data in each unit test.
*
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->api = $this->getApiMock();
$this->api->expects($this->once())
->method('get')
->with('/rate_limit')
->will($this->returnValue($this->expectedArray));
}
/**
* @test
*/
public function shouldReturnRateLimitArray()
{
$this->assertSame($this->expectedArray, $this->api->getRateLimits());
}
/**
* @test
*/
public function shouldReturnArrayOfLimitInstances()
{
$this->assertContainsOnlyInstancesOf(RateLimit\RateLimitResource::class, $this->api->getResources());
}
/**
* @test
*/
public function shouldReturnRemainingGraphQLRequests()
{
$this->assertSame(4030, $this->api->getResource('graphql')->getRemaining());
}
/**
* @test
*/
public function shouldReturnResetForSearch()
{
$this->assertSame(1372697452, $this->api->getResource('search')->getReset());
}
/**
* @test
*/
public function shouldReturnFalseWhenResourceIsNotFound()
{
$this->assertFalse($this->api->getResource('non-exitent'));
}
/**
* @return string
*/
protected function getApiClass()
{
return \Github\Api\RateLimit::class;
}
}