Skip to content

Commit

Permalink
Add helper method to determine stray request prevention state (#53232)
Browse files Browse the repository at this point in the history
Co-authored-by: Xurshudyan <[email protected]>
  • Loading branch information
xurshudyan and Xurshudyan authored Oct 21, 2024
1 parent f507e43 commit 6ff9ae1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ public function preventStrayRequests($prevent = true)
return $this;
}

/**
* Determine if stray requests are being prevented.
*
* @return bool
*/
public function preventingStrayRequests()
{
return $this->preventStrayRequests;
}

/**
* Indicate that an exception should not be thrown if any request is not faked.
*
Expand Down
9 changes: 9 additions & 0 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,15 @@ public function testItCanEnforceFaking()
$this->factory->get('https://laravel.com');
}

public function testPreventingStrayRequests()
{
$this->assertFalse($this->factory->preventingStrayRequests());

$this->factory->preventStrayRequests();

$this->assertTrue($this->factory->preventingStrayRequests());
}

public function testItCanAddAuthorizationHeaderIntoRequestUsingBeforeSendingCallback()
{
$this->factory->fake();
Expand Down

0 comments on commit 6ff9ae1

Please sign in to comment.