SessionTest::getBouncer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 1
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 SessionTest extends \PHPUnit_Framework_TestCase
15
{
16
17
    public function getRequest()
18
    {
19
        $ip = '92.78.176.182';
20
21
        $cookies = array();
22
        $cookies['bsid'] = '529460e691b0f2c87ff95acd6c4e00d2';
23
24
        $server = array();
25
        $server['REMOTE_ADDR'] = $ip;
26
27
        $request = new \Bouncer\Request;
28
        $request->initialize(array(), array(), array(), $cookies, array(), $server);
29
30
        return $request;
31
    }
32
33
    public function getBouncer($request)
34
    {
35
        $bouncer = new Bouncer(array(
36
            'request' => $request,
37
            'profile' => new \Bouncer\Profile\TestProfile,
38
        ));
39
40
        return $bouncer;
41
    }
42
43
    public function testSessionId()
44
    {
45
        $request = $this->getRequest();
46
47
        $bouncer = $this->getBouncer($request);
48
49
        $identity = $bouncer->getIdentity();
50
51
        $this->assertInstanceOf('\\Bouncer\\Resource\\Session', $identity->getSession());
52
53
        $this->assertEquals('529460e691b0f2c87ff95acd6c4e00d2', $identity->getSession()->getId());
54
    }
55
56
}
57