Completed
Push — master ( b2c31d...142309 )
by Vitaliy
01:49
created

AddApnIdHeaderVisitorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 46
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the AppleApnPush package
5
 *
6
 * (c) Vitaliy Zhuk <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code
10
 */
11
12
namespace Tests\Apple\ApnPush\Protocol\Http\Visitor;
13
14
use Apple\ApnPush\Model\Alert;
15
use Apple\ApnPush\Model\ApnId;
16
use Apple\ApnPush\Model\Aps;
17
use Apple\ApnPush\Model\Notification;
18
use Apple\ApnPush\Model\Payload;
19
use Apple\ApnPush\Protocol\Http\Request;
20
use Apple\ApnPush\Protocol\Http\Visitor\AddApnIdHeaderVisitor;
21
use PHPUnit\Framework\TestCase;
22
23
class AddApnIdHeaderVisitorTest extends TestCase
24
{
25
    /**
26
     * @var AddApnIdHeaderVisitor
27
     */
28
    private $visitor;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function setUp()
34
    {
35
        $this->visitor = new AddApnIdHeaderVisitor();
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function shouldAddHeaderForApnId()
42
    {
43
        $payload = new Payload(new Aps(new Alert()));
44
        $notification = new Notification($payload, ApnId::fromId('550e8400-e29b-41d4-a716-446655440000'));
45
        $request = new Request('https://domain.com', '{}');
46
47
        $visitedRequest = $this->visitor->visit($notification, $request);
48
49
        $headers = $visitedRequest->getHeaders();
50
51
        self::assertEquals([
52
            'apns-id' => '550e8400-e29b-41d4-a716-446655440000'
53
        ], $headers);
54
    }
55
56
    /**
57
     * @test
58
     */
59
    public function shouldNotAddHeaderForApnId()
60
    {
61
        $payload = new Payload(new Aps(new Alert()));
62
        $notification = new Notification($payload);
63
        $request = new Request('https://domain.com', '{}');
64
65
        $visitedRequest = $this->visitor->visit($notification, $request);
66
67
        $headers = $visitedRequest->getHeaders();
68
        self::assertEquals([], $headers);
69
    }
70
}
71