Skip to content

Commit

Permalink
Merge branch '5.7-streamed-content' of https://github.com/stidges/fra…
Browse files Browse the repository at this point in the history
…mework into stidges-5.7-streamed-content
  • Loading branch information
taylorotwell committed Sep 13, 2018
2 parents 25ddb27 + 6139630 commit 0c737c3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Contracts\View\View;
use Illuminate\Support\Traits\Macroable;
use PHPUnit\Framework\Assert as PHPUnit;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Foundation\Testing\Constraints\SeeInOrder;

/**
Expand All @@ -27,6 +28,13 @@ class TestResponse
*/
public $baseResponse;

/**
* The streamed content of the response.
*
* @var string
*/
protected $streamedContent;

/**
* Create a new test response instance.
*
Expand Down Expand Up @@ -949,6 +957,28 @@ public function dump()
dd($content);
}

/**
* Get the streamed content from the response.
*
* @return string
*/
public function getStreamedContent()
{
if (! is_null($this->streamedContent)) {
return $this->streamedContent;
}

if (! $this->baseResponse instanceof StreamedResponse) {
PHPUnit::fail('The response is not a streamed response.');
}

ob_start();

$this->sendContent();

return $this->streamedContent = ob_get_clean();
}

/**
* Dynamically access base response parameters.
*
Expand Down

0 comments on commit 0c737c3

Please sign in to comment.