Skip to content

Commit f55fee2

Browse files
authored
[8.x] Clear recorded calls when calling Http::fake() (#40194)
* clear recorded calls when calling Http::fake() * apply ci fixes
1 parent 2f86d4e commit f55fee2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Illuminate/Http/Client/Factory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public function fake($callback = null)
149149
{
150150
$this->record();
151151

152+
$this->recorded = [];
153+
152154
if (is_null($callback)) {
153155
$callback = function () {
154156
return static::response();

tests/Http/HttpClientTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ public function testCanSendFormData()
180180
});
181181
}
182182

183+
public function testRecordedCallsAreEmptiedWhenFakeIsCalled()
184+
{
185+
$this->factory->fake([
186+
'http://foo.com/*' => ['page' => 'foo'],
187+
]);
188+
189+
$this->factory->get('http://foo.com/test');
190+
191+
$this->factory->assertSent(function (Request $request) {
192+
return $request->url() === 'http://foo.com/test';
193+
});
194+
195+
$this->factory->fake();
196+
197+
$this->factory->assertNothingSent();
198+
}
199+
183200
public function testSpecificRequestIsNotBeingSent()
184201
{
185202
$this->factory->fake();

0 commit comments

Comments
 (0)