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 PHPUnit\Framework\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
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.