@@ -29,7 +29,10 @@ public function shouldPassGETRequestToClient()
29
29
30
30
$ api = $ this ->getAbstractApiObject ($ client );
31
31
32
- $ this ->assertEquals ($ expectedArray , $ api ->get ('/path ' , array ('param1 ' => 'param1value ' ), array ('header1 ' => 'header1value ' )));
32
+ $ method = new \ReflectionMethod ($ api , 'get ' );
33
+ $ method ->setAccessible (true );
34
+
35
+ $ this ->assertEquals ($ expectedArray , $ method ->invokeArgs ($ api , ['/path ' , array ('param1 ' => 'param1value ' ), array ('header1 ' => 'header1value ' )]));
33
36
}
34
37
35
38
/**
@@ -54,8 +57,10 @@ public function shouldPassPOSTRequestToClient()
54
57
->willReturn ($ httpClient );
55
58
56
59
$ api = $ this ->getAbstractApiObject ($ client );
60
+ $ method = new \ReflectionMethod ($ api , 'post ' );
61
+ $ method ->setAccessible (true );
57
62
58
- $ this ->assertEquals ($ expectedArray , $ api -> post ( '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )));
63
+ $ this ->assertEquals ($ expectedArray , $ method -> invokeArgs ( $ api , [ '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )] ));
59
64
}
60
65
61
66
/**
@@ -80,8 +85,10 @@ public function shouldPassPATCHRequestToClient()
80
85
->willReturn ($ httpClient );
81
86
82
87
$ api = $ this ->getAbstractApiObject ($ client );
88
+ $ method = new \ReflectionMethod ($ api , 'patch ' );
89
+ $ method ->setAccessible (true );
83
90
84
- $ this ->assertEquals ($ expectedArray , $ api -> patch ( '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )));
91
+ $ this ->assertEquals ($ expectedArray , $ method -> invokeArgs ( $ api , [ '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )] ));
85
92
}
86
93
87
94
/**
@@ -106,8 +113,10 @@ public function shouldPassPUTRequestToClient()
106
113
->willReturn ($ httpClient );
107
114
108
115
$ api = $ this ->getAbstractApiObject ($ client );
116
+ $ method = new \ReflectionMethod ($ api , 'put ' );
117
+ $ method ->setAccessible (true );
109
118
110
- $ this ->assertEquals ($ expectedArray , $ api -> put ( '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )));
119
+ $ this ->assertEquals ($ expectedArray , $ method -> invokeArgs ( $ api , [ '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )] ));
111
120
}
112
121
113
122
/**
@@ -133,8 +142,10 @@ public function shouldPassDELETERequestToClient()
133
142
134
143
135
144
$ api = $ this ->getAbstractApiObject ($ client );
145
+ $ method = new \ReflectionMethod ($ api , 'delete ' );
146
+ $ method ->setAccessible (true );
136
147
137
- $ this ->assertEquals ($ expectedArray , $ api -> delete ( '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )));
148
+ $ this ->assertEquals ($ expectedArray , $ method -> invokeArgs ( $ api , [ '/path ' , array ('param1 ' => 'param1value ' ), array ('option1 ' => 'option1value ' )] ));
138
149
}
139
150
140
151
/**
@@ -159,12 +170,22 @@ public function shouldNotPassEmptyRefToClient()
159
170
->willReturn ($ httpClient );
160
171
161
172
$ api = $ this ->getAbstractApiObject ($ client );
162
- $ api ->get ('/path ' , array ('ref ' => null ));
173
+ $ method = new \ReflectionMethod ($ api , 'get ' );
174
+ $ method ->setAccessible (true );
175
+
176
+ $ this ->assertInternalType ('array ' , $ method ->invokeArgs ($ api , ['/path ' , array ('ref ' => null )]));
163
177
}
164
178
179
+ /**
180
+ * @param $client
181
+ * @return AbstractApi
182
+ */
165
183
protected function getAbstractApiObject ($ client )
166
184
{
167
- return new AbstractApiTestInstance ($ client );
185
+ return $ this ->getMockBuilder (AbstractApi::class)
186
+ ->setMethods (null )
187
+ ->setConstructorArgs ([$ client ])
188
+ ->getMock ();
168
189
}
169
190
170
191
/**
@@ -223,68 +244,3 @@ private function getPSR7Response($expectedArray)
223
244
);
224
245
}
225
246
}
226
-
227
- class AbstractApiTestInstance extends AbstractApi
228
- {
229
- /**
230
- * {@inheritDoc}
231
- */
232
- public function get ($ path , array $ parameters = array (), $ requestHeaders = array ())
233
- {
234
- return parent ::get ($ path , $ parameters , $ requestHeaders );
235
- }
236
-
237
- /**
238
- * {@inheritDoc}
239
- */
240
- public function post ($ path , array $ parameters = array (), $ requestHeaders = array ())
241
- {
242
- return parent ::post ($ path , $ parameters , $ requestHeaders );
243
- }
244
-
245
- /**
246
- * {@inheritDoc}
247
- */
248
- public function postRaw ($ path , $ body , $ requestHeaders = array ())
249
- {
250
- return parent ::postRaw ($ path , $ body , $ requestHeaders );
251
- }
252
-
253
- /**
254
- * {@inheritDoc}
255
- */
256
- public function patch ($ path , array $ parameters = array (), $ requestHeaders = array ())
257
- {
258
- return parent ::patch ($ path , $ parameters , $ requestHeaders );
259
- }
260
-
261
- /**
262
- * {@inheritDoc}
263
- */
264
- public function put ($ path , array $ parameters = array (), $ requestHeaders = array ())
265
- {
266
- return parent ::put ($ path , $ parameters , $ requestHeaders );
267
- }
268
-
269
- /**
270
- * {@inheritDoc}
271
- */
272
- public function delete ($ path , array $ parameters = array (), $ requestHeaders = array ())
273
- {
274
- return parent ::delete ($ path , $ parameters , $ requestHeaders );
275
- }
276
- }
277
-
278
- /**
279
- * @deprecated
280
- */
281
- class ExposedAbstractApiTestInstance extends AbstractApi
282
- {
283
- /**
284
- * {@inheritDoc}
285
- */
286
- public function get ($ path , array $ parameters = array (), $ requestHeaders = array ())
287
- {
288
- return parent ::get ($ path , $ parameters , $ requestHeaders );
289
- }
290
- }
0 commit comments