@@ -190,6 +190,42 @@ public function testErrorUploadingTooFast()
190190 $ listener ->error ($ this ->getEventMock ($ response ));
191191 }
192192
193+ /**
194+ * @expectedException \Imgur\Exception\ErrorException
195+ * @expectedExceptionMessage Request to: /3/image.json failed with: "Error code: 666"
196+ */
197+ public function testErrorNoMessageInError ()
198+ {
199+ $ response = $ this ->getMockBuilder ('GuzzleHttp\Message\ResponseInterface ' )
200+ ->disableOriginalConstructor ()
201+ ->getMock ();
202+ $ response ->expects ($ this ->exactly (2 ))
203+ ->method ('getStatusCode ' )
204+ ->will ($ this ->returnValue (429 ));
205+ $ response ->expects ($ this ->once ())
206+ ->method ('getBody ' )
207+ ->will ($ this ->returnValue (json_encode (['status ' => 400 , 'success ' => false , 'data ' => ['error ' => ['code ' => 666 , 'type ' => 'ImgurException ' , 'exception ' => []], 'request ' => '/3/image.json ' , 'method ' => 'POST ' ]])));
208+ $ response ->expects ($ this ->at (1 ))
209+ ->method ('getHeader ' )
210+ ->with ('X-RateLimit-UserRemaining ' )
211+ ->will ($ this ->returnValue (9 ));
212+ $ response ->expects ($ this ->at (2 ))
213+ ->method ('getHeader ' )
214+ ->with ('X-RateLimit-UserLimit ' )
215+ ->will ($ this ->returnValue (10 ));
216+ $ response ->expects ($ this ->at (3 ))
217+ ->method ('getHeader ' )
218+ ->with ('X-RateLimit-ClientRemaining ' )
219+ ->will ($ this ->returnValue (9 ));
220+ $ response ->expects ($ this ->at (4 ))
221+ ->method ('getHeader ' )
222+ ->with ('X-RateLimit-ClientLimit ' )
223+ ->will ($ this ->returnValue (10 ));
224+
225+ $ listener = new ErrorListener ();
226+ $ listener ->error ($ this ->getEventMock ($ response ));
227+ }
228+
193229 /**
194230 * @expectedException \Imgur\Exception\RuntimeException
195231 * @expectedExceptionMessage hihi
0 commit comments