AuthSessionTest::testSetNonce()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 1
b 0
f 0
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