Passed
Push — master ( 141183...2b56eb )
by Petr
08:03
created

StatusesTest::statusesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
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
0 ignored issues
show
Unused Code introduced by
The parameter $certResult is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

28
    public function testCheckedLogin(bool $loginResult, /** @scrutinizer ignore-unused */ bool $certResult, ?int $what): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
0 ignored issues
show
Unused Code introduced by
The parameter $loginResult is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function testCheckedCert(/** @scrutinizer ignore-unused */ bool $loginResult, bool $certResult, ?int $what): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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