Completed
Push — master ( 1d87be...c3eac7 )
by François
02:15
created

IdentityTest::testGetIdentitySignature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Bouncer package.
5
 *
6
 * (c) François Hodierne <[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 Bouncer;
13
14
class IdentityTest extends \PHPUnit_Framework_TestCase
15
{
16
17
    public function getRequest()
18
    {
19
        $ip = '92.78.176.182';
20
        $ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36';
21
22
        $server = array();
23
        $server['REMOTE_ADDR'] = $ip;
24
        $server['HTTP_USER_AGENT'] = $ua;
25
        $server['HTTP_HOST'] = 'bouncer.h6e.net';
26
        $server['REQUEST_URI'] = '/test';
27
        $server['SERVER_PROTOCOL'] = 'HTTP/1.1';
28
        $server['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
29
        $server['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.8';
30
        $server['HTTP_ACCEPT_ENCODING'] = 'gzip, deflate, sdch';
31
32
        $request = new \Bouncer\Request;
33
        $request->initialize(array(), array(), array(), array(), array(), $server);
34
35
        return $request;
36
    }
37
38
    public function getBouncer($request)
39
    {
40
        $bouncer = new Bouncer(array(
41
            'request' => $request,
42
        ));
43
44
        return $bouncer;
45
    }
46
47
    public function testGetIdentity()
48
    {
49
        $request = $this->getRequest();
50
51
        $bouncer = $this->getBouncer($request);
52
53
        $identity = $bouncer->getIdentity();
54
55
        $this->assertEquals('688926c9994666d5d5d4cf7e2429aabd', $identity->getId());
56
    }
57
58
    public function testGetIdentityAddress()
59
    {
60
        $request = $this->getRequest();
61
62
        $bouncer = $this->getBouncer($request);
63
64
        $identity = $bouncer->getIdentity();
65
66
        $address = $identity->getAddress();
67
68
        $this->assertEquals('e90d9f20cce9c203f439129b0943a8bb', $address->getId());
69
    }
70
71
72
    public function testGetIdentitySignature()
73
    {
74
        $request = $this->getRequest();
75
76
        $bouncer = $this->getBouncer($request);
77
78
        $identity = $bouncer->getIdentity();
79
80
        $signature = $identity->getSignature();
81
82
        $this->assertEquals('5a8433a81c1290cc5399eb60f26172d4', $signature->getId());
83
    }
84
85
}
86