forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhoopsDisplayerTest.php
More file actions
29 lines (22 loc) · 1.06 KB
/
WhoopsDisplayerTest.php
File metadata and controls
29 lines (22 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
use Illuminate\Exception\WhoopsDisplayer;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Mockery as m;
class WhoopsDisplayerTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testStatusAndHeadersAreSetInResponse()
{
$mockWhoops = m::mock('Whoops\Run[handleException]');
$mockWhoops->shouldReceive('handleException')->andReturn('response content');
$displayer = new WhoopsDisplayer($mockWhoops, false);
$headers = array('X-My-Test-Header' => 'HeaderValue');
$exception = new HttpException(401, 'Unauthorized', null, $headers);
$response = $displayer->display($exception);
$this->assertTrue($response->headers->has('X-My-Test-Header'), "response headers should include headers provided to the exception");
$this->assertEquals('HeaderValue', $response->headers->get('X-My-Test-Header'), "response header values should match those provided to the exception");
$this->assertEquals(401, $response->getStatusCode(), "response status should match the status provided to the exception");
}
}