1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BasicTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use CommonTestClass; |
7
|
|
|
use kalanis\kw_auth\Interfaces\IUser; |
8
|
|
|
use kalanis\kw_auth\Statuses; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class StatusesTest extends CommonTestClass |
12
|
|
|
{ |
13
|
|
|
public function testAlways(): void |
14
|
|
|
{ |
15
|
|
|
$lib = new Statuses\Always(); |
16
|
|
|
$this->assertTrue($lib->allowLogin(null)); |
17
|
|
|
$this->assertTrue($lib->allowLogin(12345)); |
18
|
|
|
$this->assertTrue($lib->allowCert(null)); |
19
|
|
|
$this->assertTrue($lib->allowCert(67890)); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param bool $loginResult |
24
|
|
|
* @param bool $certResult |
25
|
|
|
* @param int|null $what |
26
|
|
|
* @dataProvider statusesProvider |
27
|
|
|
*/ |
28
|
|
|
public function testCheckedLogin(bool $loginResult, bool $certResult, ?int $what): void |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$lib = new Statuses\Checked(); |
31
|
|
|
$this->assertEquals($loginResult, $lib->allowLogin($what)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param bool $loginResult |
36
|
|
|
* @param bool $certResult |
37
|
|
|
* @param int|null $what |
38
|
|
|
* @dataProvider statusesProvider |
39
|
|
|
*/ |
40
|
|
|
public function testCheckedCert(bool $loginResult, bool $certResult, ?int $what): void |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
$lib = new Statuses\Checked(); |
43
|
|
|
$this->assertEquals($certResult, $lib->allowCert($what)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function statusesProvider(): array |
47
|
|
|
{ |
48
|
|
|
return [ |
49
|
|
|
[false, false, IUser::USER_STATUS_UNKNOWN, ], |
50
|
|
|
[false, false, IUser::USER_STATUS_DISABLED, ], |
51
|
|
|
[true, true, IUser::USER_STATUS_ENABLED, ], |
52
|
|
|
[true, false, IUser::USER_STATUS_ONLY_LOGIN, ], |
53
|
|
|
[false, true, IUser::USER_STATUS_ONLY_CERT, ], |
54
|
|
|
[false, false, 9999, ], |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.