File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
test/Bitbucket/Tests/API/Http Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ protected function createRequest($method, $url)
268268 }
269269
270270 // change the response format
271- if (strpos ($ url , 'format= ' ) === false ) {
271+ if ($ this -> getApiVersion () === ' 1.0 ' && strpos ($ url , 'format= ' ) === false ) {
272272 $ url .= (strpos ($ url , '? ' ) === false ? '? ' : '& ' ).'format= ' .$ this ->getResponseFormat ();
273273 }
274274
Original file line number Diff line number Diff line change @@ -207,6 +207,33 @@ public function testCurrentApiVersion()
207207 $ this ->assertTrue ($ client ->isApiVersion ('2 ' ));
208208 }
209209
210+ /**
211+ * @ticket 64
212+ */
213+ public function testIncludeFormatParamOnlyInV1 ()
214+ {
215+ $ endpoint = sprintf (
216+ 'repositories/gentlero/bitbucket-api/src/%s/%s ' ,
217+ 'develop ' ,
218+ 'lib/Bitbucket/API/Repositories '
219+ );
220+ $ params = $ headers = [];
221+
222+ $ baseClient = $ this ->getBrowserMock ();
223+ $ client = new Client (['api_version ' => '2.0 ' ], $ baseClient );
224+ $ client ->get ($ endpoint , $ params , $ headers );
225+
226+ /** @noinspection PhpUndefinedMethodInspection */
227+ $ req = $ client ->getLastRequest ()->getResource ();
228+ $ parts = parse_url ($ req );
229+
230+ if (false === array_key_exists ('query ' , $ parts )) {
231+ $ parts ['query ' ] = '' ;
232+ }
233+
234+ $ this ->assertFalse (strpos ($ parts ['query ' ], 'format ' ));
235+ }
236+
210237 private function getListenerMock ($ name = 'dummy ' )
211238 {
212239 $ listener = $ this ->getMock ('Bitbucket\API\Http\Listener\ListenerInterface ' );
You can’t perform that action at this time.
0 commit comments