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 = '*')
138138 /**
139139 * Indicate that an exception should be thrown if any request is not faked.
140140 *
141+ * @param bool $prevent
141142 * @return \Illuminate\Http\Client\Factory
142143 */
143- public static function preventStrayRequests ()
144+ public static function preventStrayRequests ($ prevent = true )
144145 {
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 ));
147148 });
148149 }
149150
Original file line number Diff line number Diff line change @@ -55,4 +55,15 @@ public function testFacadeRootIsSharedWhenEnforcingFaking(): void
5555
5656 $ this ->assertSame ($ client , $ this ->app ->make (Factory::class));
5757 }
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+ }
5869}
You can’t perform that action at this time.
0 commit comments