Skip to content

Commit

Permalink
Merge pull request #29033 from SjorsO/5.8
Browse files Browse the repository at this point in the history
[5.8] Make TestResponse tappable
taylorotwell authored Jul 3, 2019
2 parents 446b009 + 314b535 commit 48ab29c
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
use Illuminate\Support\Carbon;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Traits\Tappable;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Foundation\Testing\Assert as PHPUnit;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -18,7 +19,7 @@
*/
class TestResponse
{
use Macroable {
use Tappable, Macroable {
__call as macroCall;
}

11 changes: 11 additions & 0 deletions tests/Foundation/FoundationTestResponseTest.php
Original file line number Diff line number Diff line change
@@ -703,6 +703,17 @@ public function testJsonHelper()
);
}

public function testItCanBeTapped()
{
$response = TestResponse::fromBaseResponse(
(new Response)->setContent('')->setStatusCode(418)
);

$response->tap(function ($response) {
$this->assertInstanceOf(TestResponse::class, $response);
})->assertStatus(418);
}

private function makeMockResponse($content)
{
$baseResponse = tap(new Response, function ($response) use ($content) {

0 comments on commit 48ab29c

Please sign in to comment.