@@ -30,10 +30,14 @@ public function shouldFailWhenApiLimitWasExceed()
30
30
$ response ->expects ($ this ->once ())
31
31
->method ('isClientError ' )
32
32
->will ($ this ->returnValue (true ));
33
- $ response ->expects ($ this ->once ( ))
33
+ $ response ->expects ($ this ->at ( 1 ))
34
34
->method ('getHeader ' )
35
35
->with ('X-RateLimit-Remaining ' )
36
36
->will ($ this ->returnValue (0 ));
37
+ $ response ->expects ($ this ->at (2 ))
38
+ ->method ('getHeader ' )
39
+ ->with ('X-RateLimit-Limit ' )
40
+ ->will ($ this ->returnValue (5000 ));
37
41
38
42
$ listener = new ErrorListener (array ('api_limit ' => 5000 ));
39
43
$ listener ->onRequestError ($ this ->getEventMock ($ response ));
@@ -49,10 +53,15 @@ public function shouldNotPassWhenContentWasNotValidJson()
49
53
$ response ->expects ($ this ->once ())
50
54
->method ('isClientError ' )
51
55
->will ($ this ->returnValue (true ));
52
- $ response ->expects ($ this ->once ( ))
56
+ $ response ->expects ($ this ->at ( 1 ))
53
57
->method ('getHeader ' )
54
58
->with ('X-RateLimit-Remaining ' )
55
59
->will ($ this ->returnValue (5000 ));
60
+ $ response ->expects ($ this ->at (2 ))
61
+ ->method ('getHeader ' )
62
+ ->with ('X-RateLimit-Limit ' )
63
+ ->will ($ this ->returnValue (5000 ));
64
+
56
65
$ response ->expects ($ this ->once ())
57
66
->method ('getBody ' )
58
67
->will ($ this ->returnValue ('fail ' ));
@@ -71,10 +80,14 @@ public function shouldNotPassWhenContentWasValidJsonButStatusIsNotCovered()
71
80
$ response ->expects ($ this ->once ())
72
81
->method ('isClientError ' )
73
82
->will ($ this ->returnValue (true ));
74
- $ response ->expects ($ this ->once ( ))
83
+ $ response ->expects ($ this ->at ( 1 ))
75
84
->method ('getHeader ' )
76
85
->with ('X-RateLimit-Remaining ' )
77
86
->will ($ this ->returnValue (5000 ));
87
+ $ response ->expects ($ this ->at (2 ))
88
+ ->method ('getHeader ' )
89
+ ->with ('X-RateLimit-Limit ' )
90
+ ->will ($ this ->returnValue (5000 ));
78
91
$ response ->expects ($ this ->once ())
79
92
->method ('getBody ' )
80
93
->will ($ this ->returnValue (json_encode (array ('message ' => 'test ' ))));
@@ -96,10 +109,14 @@ public function shouldNotPassWhen400IsSent()
96
109
$ response ->expects ($ this ->once ())
97
110
->method ('isClientError ' )
98
111
->will ($ this ->returnValue (true ));
99
- $ response ->expects ($ this ->once ( ))
112
+ $ response ->expects ($ this ->at ( 1 ))
100
113
->method ('getHeader ' )
101
114
->with ('X-RateLimit-Remaining ' )
102
115
->will ($ this ->returnValue (5000 ));
116
+ $ response ->expects ($ this ->at (2 ))
117
+ ->method ('getHeader ' )
118
+ ->with ('X-RateLimit-Limit ' )
119
+ ->will ($ this ->returnValue (5000 ));
103
120
$ response ->expects ($ this ->once ())
104
121
->method ('getBody ' )
105
122
->will ($ this ->returnValue (json_encode (array ('message ' => 'test ' ))));
@@ -134,10 +151,14 @@ public function shouldNotPassWhen422IsSentWithErrorCode($errorCode)
134
151
$ response ->expects ($ this ->once ())
135
152
->method ('isClientError ' )
136
153
->will ($ this ->returnValue (true ));
137
- $ response ->expects ($ this ->once ( ))
154
+ $ response ->expects ($ this ->at ( 1 ))
138
155
->method ('getHeader ' )
139
156
->with ('X-RateLimit-Remaining ' )
140
157
->will ($ this ->returnValue (5000 ));
158
+ $ response ->expects ($ this ->at (2 ))
159
+ ->method ('getHeader ' )
160
+ ->with ('X-RateLimit-Limit ' )
161
+ ->will ($ this ->returnValue (5000 ));
141
162
$ response ->expects ($ this ->once ())
142
163
->method ('getBody ' )
143
164
->will ($ this ->returnValue ($ content ));
@@ -170,6 +191,8 @@ public function shouldThrowTwoFactorAuthenticationRequiredException()
170
191
return 5000 ;
171
192
case 'X-GitHub-OTP ' :
172
193
return 'required; sms ' ;
194
+ case 'X-RateLimit-Limit ' :
195
+ return 5000 ;
173
196
}
174
197
}));
175
198
$ response ->expects ($ this ->any ())
0 commit comments