File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
src/Illuminate/Http/Client Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -338,9 +338,8 @@ public function throwIfStatus($statusCode)
338
338
*/
339
339
public function throwUnlessStatus ($ statusCode )
340
340
{
341
- if (is_callable ($ statusCode ) &&
342
- ! $ statusCode ($ this ->status (), $ this )) {
343
- return $ this ->throw ();
341
+ if (is_callable ($ statusCode )) {
342
+ return $ statusCode ($ this ->status (), $ this ) ? $ this : $ this ->throw ();
344
343
}
345
344
346
345
return $ this ->status () === $ statusCode ? $ this : $ this ->throw ();
Original file line number Diff line number Diff line change @@ -2194,6 +2194,16 @@ public function testRequestExceptionIsThrownUnlessStatusCodeIsSatisfied()
2194
2194
}
2195
2195
2196
2196
$ this ->assertNull ($ exception );
2197
+
2198
+ $ exception = null ;
2199
+
2200
+ try {
2201
+ $ this ->factory ->get ('http://foo.com/api/500 ' )->throwUnlessStatus (fn ($ status ) => $ status === 500 );
2202
+ } catch (RequestException $ e ) {
2203
+ $ exception = $ e ;
2204
+ }
2205
+
2206
+ $ this ->assertNull ($ exception );
2197
2207
}
2198
2208
2199
2209
public function testRequestExceptionIsThrownIfIsClientError ()
You can’t perform that action at this time.
0 commit comments