Completed
Push — develop ( 3c50bf...126c89 )
by Stan
02:00
created

ResponseTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
use Krenor\Http2Pusher\Response;
4
use Krenor\Http2Pusher\Tests\TestCase;
5
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
        );
47
    }
48
}
49