| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class ResponseTest extends TestCase |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var Response |
||
| 10 | */ |
||
| 11 | private $response; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Bootstrap the test environment. |
||
| 15 | */ |
||
| 16 | public function setUp() |
||
| 17 | { |
||
| 18 | parent::setUp(); |
||
| 19 | |||
| 20 | $this->response = new Response(); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** @test */ |
||
| 24 | public function it_should_not_add_a_link_header_or_cookie_without_pushable_resources() |
||
| 25 | { |
||
| 26 | $this->response->pushes($this->builder, $this->nonPushable); |
||
| 27 | |||
| 28 | $headers = $this->response->headers; |
||
| 29 | |||
| 30 | $this->assertFalse($headers->has('Link')); |
||
| 31 | $this->assertCount(0, $headers->getCookies()); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** @test */ |
||
| 35 | public function it_should_add_a_link_header_and_cookie_when_given_pushable_resources() |
||
| 36 | { |
||
| 37 | $this->response->pushes($this->builder, $this->pushable); |
||
| 38 | |||
| 39 | $headers = $this->response->headers; |
||
| 40 | |||
| 41 | $this->assertTrue($headers->has('Link')); |
||
| 42 | $this->assertCount(1, $headers->getCookies()); |
||
| 43 | $this->assertSame( |
||
| 44 | $this->builderSettings['cookie']['name'], |
||
| 45 | $headers->getCookies()[0]->getName() |
||
| 46 | ); |
||
| 49 |