AuthSessionTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 28
dl 0
loc 68
rs 10
c 2
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testJsonSerializer() 0 11 1
A testSetCodeVerifier() 0 9 1
A testSetNonce() 0 9 1
A testSetState() 0 9 1
A testFromArray() 0 9 1
A testSetCustoms() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClientTest\Session;
6
7
use Facile\OpenIDClient\Session\AuthSession;
8
use function json_decode;
9
use function json_encode;
10
use Facile\OpenIDClientTest\TestCase;
11
12
class AuthSessionTest extends TestCase
13
{
14
    public function testSetState(): void
15
    {
16
        $session = new AuthSession();
17
18
        static::assertNull($session->getState());
19
20
        $session->setState('foo');
21
22
        static::assertSame('foo', $session->getState());
23
    }
24
25
    public function testSetNonce(): void
26
    {
27
        $session = new AuthSession();
28
29
        static::assertNull($session->getNonce());
30
31
        $session->setNonce('foo');
32
33
        static::assertSame('foo', $session->getNonce());
34
    }
35
36
    public function testSetCodeVerifier(): void
37
    {
38
        $session = new AuthSession();
39
40
        static::assertNull($session->getCodeVerifier());
41
42
        $session->setCodeVerifier('foo');
43
44
        static::assertSame('foo', $session->getCodeVerifier());
45
    }
46
47
    public function testSetCustoms(): void
48
    {
49
        $session = new AuthSession();
50
51
        static::assertSame([], $session->getCustoms());
52
53
        $session->setCustoms(['foo' => 'bar']);
54
55
        static::assertSame(['foo' => 'bar'], $session->getCustoms());
56
    }
57
58
    public function testFromArray(): void
59
    {
60
        $session = AuthSession::fromArray([
61
            'state' => 'foo',
62
            'nonce' => 'bar',
63
        ]);
64
65
        static::assertSame('foo', $session->getState());
66
        static::assertSame('bar', $session->getNonce());
67
    }
68
69
    public function testJsonSerializer(): void
70
    {
71
        $session = AuthSession::fromArray([
72
            'state' => 'foo',
73
            'nonce' => 'bar',
74
        ]);
75
76
        static::assertSame([
77
            'state' => 'foo',
78
            'nonce' => 'bar',
79
        ], json_decode(json_encode($session), true));
80
    }
81
}
82