Skip to content

Commit 6ff9ae1

Browse files
xurshudyanXurshudyan
and
Xurshudyan
authored
Add helper method to determine stray request prevention state (#53232)
Co-authored-by: Xurshudyan <[email protected]>
1 parent f507e43 commit 6ff9ae1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Illuminate/Http/Client/Factory.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,16 @@ public function preventStrayRequests($prevent = true)
267267
return $this;
268268
}
269269

270+
/**
271+
* Determine if stray requests are being prevented.
272+
*
273+
* @return bool
274+
*/
275+
public function preventingStrayRequests()
276+
{
277+
return $this->preventStrayRequests;
278+
}
279+
270280
/**
271281
* Indicate that an exception should not be thrown if any request is not faked.
272282
*

tests/Http/HttpClientTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,6 +2907,15 @@ public function testItCanEnforceFaking()
29072907
$this->factory->get('https://laravel.com');
29082908
}
29092909

2910+
public function testPreventingStrayRequests()
2911+
{
2912+
$this->assertFalse($this->factory->preventingStrayRequests());
2913+
2914+
$this->factory->preventStrayRequests();
2915+
2916+
$this->assertTrue($this->factory->preventingStrayRequests());
2917+
}
2918+
29102919
public function testItCanAddAuthorizationHeaderIntoRequestUsingBeforeSendingCallback()
29112920
{
29122921
$this->factory->fake();

0 commit comments

Comments
 (0)