Skip to content

Commit

Permalink
Ensure ExceptionRendererTest does not output anything
Browse files Browse the repository at this point in the history
  • Loading branch information
peteraba committed May 2, 2021
1 parent a07ebb6 commit f01582a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/Debug/Exceptions/Handlers/Whoops/ExceptionRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

class ExceptionRendererTest extends TestCase
{
public function setUp(): void
{
ob_start();
}

public function tearDown(): void
{
ob_clean();
ob_end_flush();
}

public function testGetRunReturnsRunSet(): void
{
/** @var MockObject|RunInterface $runMock */
Expand Down Expand Up @@ -61,8 +72,6 @@ public function testRenderHttpExceptionInDevelopmentWithJsonRequest(): void
{
$expectedOutputString = 'foo';

$this->expectOutputString($expectedOutputString);

$isDevelopmentEnvironment = false;

$exceptionStub = new HttpException(505, $expectedOutputString, ['foo' => 'bar']);
Expand All @@ -83,14 +92,14 @@ public function testRenderHttpExceptionInDevelopmentWithJsonRequest(): void
$this->assertCount(3, $headers);
$this->assertSame('foo:bar', $headers[1][0]);
$this->assertSame('Content-Type:application/json', $headers[2][0]);

$this->assertSame($expectedOutputString, ob_get_contents());
}

public function testRenderHttpExceptionInDevelopmentWithHttpRequest(): void
{
$expectedOutputString = 'foo';

$this->expectOutputRegex(sprintf('/%s/', $expectedOutputString));

$isDevelopmentEnvironment = false;

$exceptionStub = new Exception($expectedOutputString);
Expand All @@ -110,5 +119,7 @@ public function testRenderHttpExceptionInDevelopmentWithHttpRequest(): void
$headers = $sut->getHeaders();
$this->assertCount(2, $headers);
$this->assertSame('Content-Type:text/html', $headers[1][0]);

$this->assertStringContainsString($expectedOutputString, ob_get_contents());
}
}

0 comments on commit f01582a

Please sign in to comment.