@@ -30,10 +30,14 @@ public function shouldFailWhenApiLimitWasExceed()
3030 $ response ->expects ($ this ->once ())
3131 ->method ('isClientError ' )
3232 ->will ($ this ->returnValue (true ));
33- $ response ->expects ($ this ->once ( ))
33+ $ response ->expects ($ this ->at ( 1 ))
3434 ->method ('getHeader ' )
3535 ->with ('X-RateLimit-Remaining ' )
3636 ->will ($ this ->returnValue (0 ));
37+ $ response ->expects ($ this ->at (2 ))
38+ ->method ('getHeader ' )
39+ ->with ('X-RateLimit-Limit ' )
40+ ->will ($ this ->returnValue (5000 ));
3741
3842 $ listener = new ErrorListener (array ('api_limit ' => 5000 ));
3943 $ listener ->onRequestError ($ this ->getEventMock ($ response ));
@@ -49,10 +53,15 @@ public function shouldNotPassWhenContentWasNotValidJson()
4953 $ response ->expects ($ this ->once ())
5054 ->method ('isClientError ' )
5155 ->will ($ this ->returnValue (true ));
52- $ response ->expects ($ this ->once ( ))
56+ $ response ->expects ($ this ->at ( 1 ))
5357 ->method ('getHeader ' )
5458 ->with ('X-RateLimit-Remaining ' )
5559 ->will ($ this ->returnValue (5000 ));
60+ $ response ->expects ($ this ->at (2 ))
61+ ->method ('getHeader ' )
62+ ->with ('X-RateLimit-Limit ' )
63+ ->will ($ this ->returnValue (5000 ));
64+
5665 $ response ->expects ($ this ->once ())
5766 ->method ('getBody ' )
5867 ->will ($ this ->returnValue ('fail ' ));
@@ -71,10 +80,14 @@ public function shouldNotPassWhenContentWasValidJsonButStatusIsNotCovered()
7180 $ response ->expects ($ this ->once ())
7281 ->method ('isClientError ' )
7382 ->will ($ this ->returnValue (true ));
74- $ response ->expects ($ this ->once ( ))
83+ $ response ->expects ($ this ->at ( 1 ))
7584 ->method ('getHeader ' )
7685 ->with ('X-RateLimit-Remaining ' )
7786 ->will ($ this ->returnValue (5000 ));
87+ $ response ->expects ($ this ->at (2 ))
88+ ->method ('getHeader ' )
89+ ->with ('X-RateLimit-Limit ' )
90+ ->will ($ this ->returnValue (5000 ));
7891 $ response ->expects ($ this ->once ())
7992 ->method ('getBody ' )
8093 ->will ($ this ->returnValue (json_encode (array ('message ' => 'test ' ))));
@@ -96,10 +109,14 @@ public function shouldNotPassWhen400IsSent()
96109 $ response ->expects ($ this ->once ())
97110 ->method ('isClientError ' )
98111 ->will ($ this ->returnValue (true ));
99- $ response ->expects ($ this ->once ( ))
112+ $ response ->expects ($ this ->at ( 1 ))
100113 ->method ('getHeader ' )
101114 ->with ('X-RateLimit-Remaining ' )
102115 ->will ($ this ->returnValue (5000 ));
116+ $ response ->expects ($ this ->at (2 ))
117+ ->method ('getHeader ' )
118+ ->with ('X-RateLimit-Limit ' )
119+ ->will ($ this ->returnValue (5000 ));
103120 $ response ->expects ($ this ->once ())
104121 ->method ('getBody ' )
105122 ->will ($ this ->returnValue (json_encode (array ('message ' => 'test ' ))));
@@ -134,10 +151,14 @@ public function shouldNotPassWhen422IsSentWithErrorCode($errorCode)
134151 $ response ->expects ($ this ->once ())
135152 ->method ('isClientError ' )
136153 ->will ($ this ->returnValue (true ));
137- $ response ->expects ($ this ->once ( ))
154+ $ response ->expects ($ this ->at ( 1 ))
138155 ->method ('getHeader ' )
139156 ->with ('X-RateLimit-Remaining ' )
140157 ->will ($ this ->returnValue (5000 ));
158+ $ response ->expects ($ this ->at (2 ))
159+ ->method ('getHeader ' )
160+ ->with ('X-RateLimit-Limit ' )
161+ ->will ($ this ->returnValue (5000 ));
141162 $ response ->expects ($ this ->once ())
142163 ->method ('getBody ' )
143164 ->will ($ this ->returnValue ($ content ));
@@ -170,6 +191,8 @@ public function shouldThrowTwoFactorAuthenticationRequiredException()
170191 return 5000 ;
171192 case 'X-GitHub-OTP ' :
172193 return 'required; sms ' ;
194+ case 'X-RateLimit-Limit ' :
195+ return 5000 ;
173196 }
174197 }));
175198 $ response ->expects ($ this ->any ())
0 commit comments