@@ -25,7 +25,7 @@ public function shouldGetAllResults()
25
25
{
26
26
$ amountLoops = 3 ;
27
27
$ content = array (1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 );
28
- $ responseMock = new TestResponse ( $ amountLoops , $ content );
28
+ $ responseMock = new TestResponse ($ amountLoops , $ content );
29
29
30
30
// httpClient mock
31
31
$ httpClientMock = $ this ->getHttpClientMock ($ responseMock );
@@ -37,7 +37,7 @@ public function shouldGetAllResults()
37
37
$ clientMock = $ this ->getClientMock ($ httpClientMock );
38
38
39
39
// memberApi Mock
40
- $ memberApiMock = $ this ->getApiMock ( 'Github\Api\Organization\Members ' );
40
+ $ memberApiMock = $ this ->getApiMock ('Github\Api\Organization\Members ' );
41
41
$ memberApiMock
42
42
->expects ($ this ->once ())
43
43
->method ('all ' )
@@ -47,8 +47,8 @@ public function shouldGetAllResults()
47
47
$ parameters = array ('netwerven ' );
48
48
49
49
// Run fetchAll on result paginator
50
- $ paginator = new Github \ResultPager ( $ clientMock );
51
- $ result = $ paginator ->fetchAll ( $ memberApiMock , $ method , $ parameters );
50
+ $ paginator = new Github \ResultPager ($ clientMock );
51
+ $ result = $ paginator ->fetchAll ($ memberApiMock , $ method , $ parameters );
52
52
53
53
$ this ->assertEquals ($ amountLoops * count ($ content ), count ($ result ));
54
54
}
@@ -64,19 +64,19 @@ public function shouldGetSomeResults()
64
64
$ resultContent = 'organization test ' ;
65
65
66
66
$ responseMock = $ this ->getResponseMock ($ pagination );
67
- $ httpClient = $ this ->getHttpClientMock ( $ responseMock );
67
+ $ httpClient = $ this ->getHttpClientMock ($ responseMock );
68
68
$ client = $ this ->getClientMock ($ httpClient );
69
69
70
- $ organizationApiMock = $ this ->getApiMock ( 'Github\Api\Organization ' );
70
+ $ organizationApiMock = $ this ->getApiMock ('Github\Api\Organization ' );
71
71
72
72
$ organizationApiMock
73
73
->expects ($ this ->once ())
74
74
->method ('show ' )
75
75
->with ('github ' )
76
76
->will ($ this ->returnValue ($ resultContent ));
77
77
78
- $ paginator = new Github \ResultPager ( $ client );
79
- $ result = $ paginator ->fetch ($ organizationApiMock , 'show ' , 'github ' );
78
+ $ paginator = new Github \ResultPager ($ client );
79
+ $ result = $ paginator ->fetch ($ organizationApiMock , 'show ' , array ( 'github ' ) );
80
80
81
81
$ this ->assertEquals ($ resultContent , $ result );
82
82
$ this ->assertEquals ($ pagination , $ paginator ->getPagination ());
@@ -103,10 +103,10 @@ public function postFetch()
103
103
->method ('getPagination ' )
104
104
->will ($ this ->returnValue ($ pagination ));
105
105
106
- $ httpClient = $ this ->getHttpClientMock ( $ responseMock );
106
+ $ httpClient = $ this ->getHttpClientMock ($ responseMock );
107
107
$ client = $ this ->getClientMock ($ httpClient );
108
108
109
- $ paginator = new Github \ResultPager ( $ client );
109
+ $ paginator = new Github \ResultPager ($ client );
110
110
$ paginator ->postFetch ();
111
111
112
112
$ this ->assertEquals ($ paginator ->getPagination (), $ pagination );
@@ -122,7 +122,7 @@ public function fetchNext()
122
122
$ pagination = array ('next ' => 'http://github.com/next ' );
123
123
$ resultContent = 'fetch test ' ;
124
124
125
- $ responseMock = $ this ->getResponseMock ( $ pagination );
125
+ $ responseMock = $ this ->getResponseMock ($ pagination );
126
126
$ responseMock
127
127
->expects ($ this ->once ())
128
128
->method ('getContent ' )
@@ -132,17 +132,17 @@ public function fetchNext()
132
132
->expects ($ this ->exactly (2 ))
133
133
->method ('getPagination ' );
134
134
135
- $ httpClient = $ this ->getHttpClientMock ( $ responseMock );
135
+ $ httpClient = $ this ->getHttpClientMock ($ responseMock );
136
136
137
137
$ httpClient
138
138
->expects ($ this ->once ())
139
139
->method ('get ' )
140
- ->with ( $ pagination ['next ' ] )
140
+ ->with ($ pagination ['next ' ])
141
141
->will ($ this ->returnValue ($ responseMock ));
142
142
143
143
$ client = $ this ->getClientMock ($ httpClient );
144
144
145
- $ paginator = new Github \ResultPager ( $ client );
145
+ $ paginator = new Github \ResultPager ($ client );
146
146
$ paginator ->postFetch ();
147
147
148
148
$ this ->assertEquals ($ paginator ->fetchNext (), $ resultContent );
@@ -156,10 +156,10 @@ public function fetchNext()
156
156
public function shouldHaveNext ()
157
157
{
158
158
$ responseMock = $ this ->getResponseMock (array ('next ' => 'http://github.com/next ' ));
159
- $ httpClient = $ this ->getHttpClientMock ( $ responseMock );
159
+ $ httpClient = $ this ->getHttpClientMock ($ responseMock );
160
160
$ client = $ this ->getClientMock ($ httpClient );
161
161
162
- $ paginator = new Github \ResultPager ( $ client );
162
+ $ paginator = new Github \ResultPager ($ client );
163
163
$ paginator ->postFetch ();
164
164
165
165
$ this ->assertEquals ($ paginator ->hasNext (), true );
@@ -174,34 +174,32 @@ public function shouldHaveNext()
174
174
public function shouldHavePrevious ()
175
175
{
176
176
$ responseMock = $ this ->getResponseMock (array ('prev ' => 'http://github.com/previous ' ));
177
- $ httpClient = $ this ->getHttpClientMock ( $ responseMock );
177
+ $ httpClient = $ this ->getHttpClientMock ($ responseMock );
178
178
$ client = $ this ->getClientMock ($ httpClient );
179
179
180
- $ paginator = new Github \ResultPager ( $ client );
180
+ $ paginator = new Github \ResultPager ($ client );
181
181
$ paginator ->postFetch ();
182
182
183
183
$ this ->assertEquals ($ paginator ->hasPrevious (), true );
184
184
$ this ->assertEquals ($ paginator ->hasNext (), false );
185
185
}
186
186
187
- protected function getResponseMock ( array $ pagination )
187
+ protected function getResponseMock (array $ pagination )
188
188
{
189
189
// response mock
190
190
$ responseMock = $ this ->getMock ('Github\HttpClient\Message\Response ' );
191
191
$ responseMock
192
192
->expects ($ this ->any ())
193
193
->method ('getPagination ' )
194
- ->will ($ this ->returnValue (
195
- $ pagination
196
- ));
194
+ ->will ($ this ->returnValue ($ pagination ));
197
195
198
196
return $ responseMock ;
199
197
}
200
198
201
- protected function getClientMock ( HttpClientInterface $ httpClient = null )
199
+ protected function getClientMock (HttpClientInterface $ httpClient = null )
202
200
{
203
201
// if no httpClient isset use the default HttpClient mock
204
- if ( !$ httpClient ) {
202
+ if ( !$ httpClient) {
205
203
$ httpClient = $ this ->getHttpClientMock ();
206
204
}
207
205
@@ -211,7 +209,7 @@ protected function getClientMock( HttpClientInterface $httpClient = null )
211
209
return $ client ;
212
210
}
213
211
214
- protected function getHttpClientMock ( $ responseMock = null )
212
+ protected function getHttpClientMock ($ responseMock = null )
215
213
{
216
214
// mock the client interface
217
215
$ clientInterfaceMock = $ this ->getMock ('Buzz\Client\ClientInterface ' , array ('setTimeout ' , 'setVerifyPeer ' , 'send ' ));
@@ -230,7 +228,7 @@ protected function getHttpClientMock( $responseMock = null )
230
228
// create the httpClient mock
231
229
$ httpClientMock = $ this ->getMock ('Github\HttpClient\HttpClient ' , array (), array (array (), $ clientInterfaceMock ));
232
230
233
- if ( $ responseMock ) {
231
+ if ( $ responseMock) {
234
232
$ httpClientMock
235
233
->expects ($ this ->any ())
236
234
->method ('getLastResponse ' )
@@ -240,12 +238,12 @@ protected function getHttpClientMock( $responseMock = null )
240
238
return $ httpClientMock ;
241
239
}
242
240
243
- protected function getApiMock ( $ apiClass )
241
+ protected function getApiMock ($ apiClass )
244
242
{
245
243
$ client = $ this ->getClientMock ();
246
244
247
- return $ this ->getMockBuilder ( $ apiClass )
245
+ return $ this ->getMockBuilder ($ apiClass )
248
246
->setConstructorArgs (array ($ client ))
249
247
->getMock ();
250
248
}
251
- }
249
+ }
0 commit comments