|
16 | 16 | */ |
17 | 17 | class GithubObjectTest extends GitHubTestCase |
18 | 18 | { |
19 | | - /** |
20 | | - * @var ObjectMock Object under test. |
21 | | - * @since 1.0 |
22 | | - */ |
23 | | - protected $object; |
| 19 | + /** |
| 20 | + * @var ObjectMock Object under test. |
| 21 | + * @since 1.0 |
| 22 | + */ |
| 23 | + protected $object; |
24 | 24 |
|
25 | | - /** |
26 | | - * Sets up the fixture, for example, opens a network connection. |
27 | | - * This method is called before a test is executed. |
28 | | - * |
29 | | - * @return void |
30 | | - * |
31 | | - * @since 1.0 |
32 | | - */ |
33 | | - protected function setUp(): void |
34 | | - { |
35 | | - parent::setUp(); |
| 25 | + /** |
| 26 | + * Sets up the fixture, for example, opens a network connection. |
| 27 | + * This method is called before a test is executed. |
| 28 | + * |
| 29 | + * @return void |
| 30 | + * |
| 31 | + * @since 1.0 |
| 32 | + */ |
| 33 | + protected function setUp(): void |
| 34 | + { |
| 35 | + parent::setUp(); |
36 | 36 |
|
37 | | - $this->object = new ObjectMock($this->options, $this->client); |
38 | | - } |
| 37 | + $this->object = new ObjectMock($this->options, $this->client); |
| 38 | + } |
39 | 39 |
|
40 | | - /** |
41 | | - * Data provider method for the fetchUrl method tests. |
42 | | - * |
43 | | - * @return array |
44 | | - * |
45 | | - * @since 1.0 |
46 | | - */ |
47 | | - public function fetchUrlData() |
48 | | - { |
49 | | - return array( |
50 | | - 'Standard github - no pagination data' => array( |
51 | | - 'https://api.github.com', |
52 | | - '/gists', |
53 | | - 0, |
54 | | - 0, |
55 | | - 'https://api.github.com/gists' |
56 | | - ), |
57 | | - 'Enterprise github - no pagination data' => array( |
58 | | - 'https://mygithub.com', |
59 | | - '/gists', |
60 | | - 0, |
61 | | - 0, |
62 | | - 'https://mygithub.com/gists' |
63 | | - ), |
64 | | - 'Standard github - page 3' => array( |
65 | | - 'https://api.github.com', |
66 | | - '/gists', |
67 | | - 3, |
68 | | - 0, |
69 | | - 'https://api.github.com/gists?page=3' |
70 | | - ), |
71 | | - 'Enterprise github - page 3, 50 per page' => array( |
72 | | - 'https://mygithub.com', |
73 | | - '/gists', |
74 | | - 3, |
75 | | - 50, |
76 | | - 'https://mygithub.com/gists?page=3&per_page=50' |
77 | | - ), |
78 | | - ); |
79 | | - } |
| 40 | + /** |
| 41 | + * Data provider method for the fetchUrl method tests. |
| 42 | + * |
| 43 | + * @return array |
| 44 | + * |
| 45 | + * @since 1.0 |
| 46 | + */ |
| 47 | + public function fetchUrlData() |
| 48 | + { |
| 49 | + return [ |
| 50 | + 'Standard github - no pagination data' => [ |
| 51 | + 'https://api.github.com', |
| 52 | + '/gists', |
| 53 | + 0, |
| 54 | + 0, |
| 55 | + 'https://api.github.com/gists', |
| 56 | + ], |
| 57 | + 'Enterprise github - no pagination data' => [ |
| 58 | + 'https://mygithub.com', |
| 59 | + '/gists', |
| 60 | + 0, |
| 61 | + 0, |
| 62 | + 'https://mygithub.com/gists', |
| 63 | + ], |
| 64 | + 'Standard github - page 3' => [ |
| 65 | + 'https://api.github.com', |
| 66 | + '/gists', |
| 67 | + 3, |
| 68 | + 0, |
| 69 | + 'https://api.github.com/gists?page=3', |
| 70 | + ], |
| 71 | + 'Enterprise github - page 3, 50 per page' => [ |
| 72 | + 'https://mygithub.com', |
| 73 | + '/gists', |
| 74 | + 3, |
| 75 | + 50, |
| 76 | + 'https://mygithub.com/gists?page=3&per_page=50', |
| 77 | + ], |
| 78 | + ]; |
| 79 | + } |
80 | 80 |
|
81 | | - /** |
82 | | - * Tests the fetchUrl method |
83 | | - * |
84 | | - * @param string $apiUrl @todo |
85 | | - * @param string $path @todo |
86 | | - * @param integer $page @todo |
87 | | - * @param integer $limit @todo |
88 | | - * @param string $expected @todo |
89 | | - * |
90 | | - * @return void |
91 | | - * |
92 | | - * @since 1.0 |
93 | | - * @dataProvider fetchUrlData |
94 | | - */ |
95 | | - public function testFetchUrl($apiUrl, $path, $page, $limit, $expected) |
96 | | - { |
97 | | - $this->options->set('api.url', $apiUrl); |
| 81 | + /** |
| 82 | + * Tests the fetchUrl method |
| 83 | + * |
| 84 | + * @param string $apiUrl @todo |
| 85 | + * @param string $path @todo |
| 86 | + * @param integer $page @todo |
| 87 | + * @param integer $limit @todo |
| 88 | + * @param string $expected @todo |
| 89 | + * |
| 90 | + * @return void |
| 91 | + * |
| 92 | + * @since 1.0 |
| 93 | + * @dataProvider fetchUrlData |
| 94 | + */ |
| 95 | + public function testFetchUrl($apiUrl, $path, $page, $limit, $expected) |
| 96 | + { |
| 97 | + $this->options->set('api.url', $apiUrl); |
98 | 98 |
|
99 | | - $this->assertThat( |
100 | | - $this->object->fetchUrl($path, $page, $limit), |
101 | | - $this->equalTo($expected) |
102 | | - ); |
103 | | - } |
| 99 | + $this->assertThat( |
| 100 | + $this->object->fetchUrl($path, $page, $limit), |
| 101 | + $this->equalTo($expected) |
| 102 | + ); |
| 103 | + } |
104 | 104 |
|
105 | | - /** |
106 | | - * Tests the fetchUrl method with basic authentication data |
107 | | - * |
108 | | - * @return void |
109 | | - * |
110 | | - * @since 1.0 |
111 | | - */ |
112 | | - public function testFetchUrlBasicAuth() |
113 | | - { |
114 | | - $this->options->set('api.url', 'https://api.github.com'); |
| 105 | + /** |
| 106 | + * Tests the fetchUrl method with basic authentication data |
| 107 | + * |
| 108 | + * @return void |
| 109 | + * |
| 110 | + * @since 1.0 |
| 111 | + */ |
| 112 | + public function testFetchUrlBasicAuth() |
| 113 | + { |
| 114 | + $this->options->set('api.url', 'https://api.github.com'); |
115 | 115 |
|
116 | | - $this->options->set('api.username', 'MyTestUser'); |
117 | | - $this->options->set('api.password', 'MyTestPass'); |
| 116 | + $this->options->set('api.username', 'MyTestUser'); |
| 117 | + $this->options->set('api.password', 'MyTestPass'); |
118 | 118 |
|
119 | | - $this->assertThat( |
120 | | - $this->object->fetchUrl('/gists', 0, 0), |
121 | | - $this->equalTo('https://MyTestUser:MyTestPass@api.github.com/gists'), |
122 | | - 'URL is not as expected.' |
123 | | - ); |
124 | | - } |
| 119 | + $this->assertThat( |
| 120 | + $this->object->fetchUrl('/gists', 0, 0), |
| 121 | + $this->equalTo('https://MyTestUser:MyTestPass@api.github.com/gists'), |
| 122 | + 'URL is not as expected.' |
| 123 | + ); |
| 124 | + } |
125 | 125 |
|
126 | | - /** |
127 | | - * Tests the fetchUrl method using an oAuth token. |
128 | | - * |
129 | | - * @return void |
130 | | - */ |
131 | | - public function testFetchUrlToken() |
132 | | - { |
133 | | - $this->options->set('api.url', 'https://api.github.com'); |
| 126 | + /** |
| 127 | + * Tests the fetchUrl method using an oAuth token. |
| 128 | + * |
| 129 | + * @return void |
| 130 | + */ |
| 131 | + public function testFetchUrlToken() |
| 132 | + { |
| 133 | + $this->options->set('api.url', 'https://api.github.com'); |
134 | 134 |
|
135 | | - $this->options->set('gh.token', 'MyTestToken'); |
| 135 | + $this->options->set('gh.token', 'MyTestToken'); |
136 | 136 |
|
137 | | - $this->assertThat( |
138 | | - (string) $this->object->fetchUrl('/gists', 0, 0), |
139 | | - $this->equalTo('https://api.github.com/gists'), |
140 | | - 'URL is not as expected.' |
141 | | - ); |
| 137 | + $this->assertThat( |
| 138 | + (string) $this->object->fetchUrl('/gists', 0, 0), |
| 139 | + $this->equalTo('https://api.github.com/gists'), |
| 140 | + 'URL is not as expected.' |
| 141 | + ); |
142 | 142 |
|
143 | | - $this->assertThat( |
144 | | - $this->client->getOption('headers'), |
145 | | - $this->equalTo(['Authorization' => 'token MyTestToken']), |
146 | | - 'Token should be propagated as a header.' |
147 | | - ); |
148 | | - } |
| 143 | + $this->assertThat( |
| 144 | + $this->client->getOption('headers'), |
| 145 | + $this->equalTo(['Authorization' => 'token MyTestToken']), |
| 146 | + 'Token should be propagated as a header.' |
| 147 | + ); |
| 148 | + } |
149 | 149 | } |
0 commit comments