File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
src/Illuminate/Support/Facades Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,13 @@ public static function fakeSequence(string $urlPattern = '*')
138
138
/**
139
139
* Indicate that an exception should be thrown if any request is not faked.
140
140
*
141
+ * @param bool $prevent
141
142
* @return \Illuminate\Http\Client\Factory
142
143
*/
143
- public static function preventStrayRequests ()
144
+ public static function preventStrayRequests ($ prevent = true )
144
145
{
145
- return tap (static ::getFacadeRoot (), function ($ fake ) {
146
- static ::swap ($ fake ->preventStrayRequests ());
146
+ return tap (static ::getFacadeRoot (), function ($ fake ) use ( $ prevent ) {
147
+ static ::swap ($ fake ->preventStrayRequests ($ prevent ));
147
148
});
148
149
}
149
150
Original file line number Diff line number Diff line change @@ -55,4 +55,15 @@ public function testFacadeRootIsSharedWhenEnforcingFaking(): void
55
55
56
56
$ this ->assertSame ($ client , $ this ->app ->make (Factory::class));
57
57
}
58
+
59
+ public function test_can_set_prevents_to_prevents_stray_requests (): void
60
+ {
61
+ Http::preventStrayRequests (true );
62
+ $ this ->assertTrue ($ this ->app ->make (Factory::class)->preventingStrayRequests ());
63
+ $ this ->assertTrue (Http::preventingStrayRequests ());
64
+
65
+ Http::preventStrayRequests (false );
66
+ $ this ->assertFalse ($ this ->app ->make (Factory::class)->preventingStrayRequests ());
67
+ $ this ->assertFalse (Http::preventingStrayRequests ());
68
+ }
58
69
}
You can’t perform that action at this time.
0 commit comments