TokenSetTest::testGetCodeVerifier()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
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 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClientTest\Token;
6
7
use Facile\OpenIDClient\Token\TokenSet;
8
use Facile\OpenIDClientTest\TestCase;
9
10
class TokenSetTest extends TestCase
11
{
12
    public function testGetTokenType(): void
13
    {
14
        $authResponse = TokenSet::fromParams([]);
15
        static::assertNull($authResponse->getTokenType());
16
17
        $authResponse = TokenSet::fromParams(['token_type' => 'foo']);
18
        static::assertSame('foo', $authResponse->getTokenType());
19
    }
20
21
    public function testGetCode(): void
22
    {
23
        $authResponse = TokenSet::fromParams([]);
24
        static::assertNull($authResponse->getCode());
25
26
        $authResponse = TokenSet::fromParams(['code' => 'foo']);
27
        static::assertSame('foo', $authResponse->getCode());
28
    }
29
30
    public function testGetExpiresIn(): void
31
    {
32
        $authResponse = TokenSet::fromParams([]);
33
        static::assertNull($authResponse->getExpiresIn());
34
35
        $authResponse = TokenSet::fromParams(['expires_in' => '3']);
36
        static::assertSame(3, $authResponse->getExpiresIn());
37
    }
38
39
    public function testGetIdToken(): void
40
    {
41
        $authResponse = TokenSet::fromParams([]);
42
        static::assertNull($authResponse->getIdToken());
43
44
        $authResponse = TokenSet::fromParams(['id_token' => 'foo']);
45
        static::assertSame('foo', $authResponse->getIdToken());
46
    }
47
48
    public function testGetRefreshToken(): void
49
    {
50
        $authResponse = TokenSet::fromParams([]);
51
        static::assertNull($authResponse->getRefreshToken());
52
53
        $authResponse = TokenSet::fromParams(['refresh_token' => 'foo']);
54
        static::assertSame('foo', $authResponse->getRefreshToken());
55
    }
56
57
    public function testGetCodeVerifier(): void
58
    {
59
        $authResponse = TokenSet::fromParams([]);
60
        static::assertNull($authResponse->getCodeVerifier());
61
62
        $authResponse = TokenSet::fromParams(['code_verifier' => 'foo']);
63
        static::assertSame('foo', $authResponse->getCodeVerifier());
64
    }
65
66
    public function testGetState(): void
67
    {
68
        $authResponse = TokenSet::fromParams([]);
69
        static::assertNull($authResponse->getState());
70
71
        $authResponse = TokenSet::fromParams(['state' => 'foo']);
72
        static::assertSame('foo', $authResponse->getState());
73
    }
74
75
    public function testGetAccessToken(): void
76
    {
77
        $authResponse = TokenSet::fromParams([]);
78
        static::assertNull($authResponse->getAccessToken());
79
80
        $authResponse = TokenSet::fromParams(['access_token' => 'foo']);
81
        static::assertSame('foo', $authResponse->getAccessToken());
82
    }
83
}
84