Skip to content

Commit

Permalink
[8.x] Clear recorded calls when calling Http::fake() (#40194)
Browse files Browse the repository at this point in the history
* clear recorded calls when calling Http::fake()

* apply ci fixes
  • Loading branch information
mateusjunges authored Dec 30, 2021
1 parent 2f86d4e commit f55fee2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public function fake($callback = null)
{
$this->record();

$this->recorded = [];

if (is_null($callback)) {
$callback = function () {
return static::response();
Expand Down
17 changes: 17 additions & 0 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ public function testCanSendFormData()
});
}

public function testRecordedCallsAreEmptiedWhenFakeIsCalled()
{
$this->factory->fake([
'http://foo.com/*' => ['page' => 'foo'],
]);

$this->factory->get('http://foo.com/test');

$this->factory->assertSent(function (Request $request) {
return $request->url() === 'http://foo.com/test';
});

$this->factory->fake();

$this->factory->assertNothingSent();
}

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

0 comments on commit f55fee2

Please sign in to comment.