Passed
Push — master ( e729e7...b0febc )
by Jakub
01:57
created

SkipCheckerTest   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 14
eloc 32
c 2
b 0
f 1
dl 0
loc 87
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSkipValue() 0 10 1
A getSkipChecker() 0 3 1
A testCheckLoadedExtension() 0 4 1
A testCheckPhpVersion() 0 4 1
A testShouldSkip() 0 10 1
A skipInteger() 0 3 1
A skipFalse() 0 3 1
A skipArrayUnknown() 0 3 1
A skipArray() 0 3 1
A testCheckPhpSapi() 0 4 1
A skipNull() 0 2 1
A skipString() 0 3 1
A skipFloat() 0 3 1
A skip() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MyTester;
6
7
use MyTester\Attributes\Skip;
8
use MyTester\Attributes\TestSuite;
9
10
/**
11
 * Test suite for class SkipChecker
12
 *
13
 * @author Jakub Konečný
14
 */
15
#[TestSuite("SkipChecker")]
16
final class SkipCheckerTest extends TestCase
17
{
18
    private function getSkipChecker(): SkipChecker
19
    {
20
        return $this->skipChecker;
21
    }
22
23
    public function testCheckPhpVersion(): void
24
    {
25
        $this->assertNull($this->getSkipChecker()->checkPhpVersion(1));
26
        $this->assertType("string", $this->getSkipChecker()->checkPhpVersion(PHP_INT_MAX));
27
    }
28
29
    public function testCheckLoadedExtension(): void
30
    {
31
        $this->assertNull($this->getSkipChecker()->checkLoadedExtension("ctype"));
32
        $this->assertType("string", $this->getSkipChecker()->checkLoadedExtension("abc"));
33
    }
34
35
    public function testCheckPhpSapi(): void
36
    {
37
        $this->assertNull($this->getSkipChecker()->checkPhpSapi(PHP_SAPI));
38
        $this->assertType("string", $this->getSkipChecker()->checkPhpSapi("abc"));
39
    }
40
41
    public function testGetSkipValue(): void
42
    {
43
        $this->assertNull($this->getSkipChecker()->getSkipValue(static::class, "skipNull"));
44
        $this->assertTrue($this->getSkipChecker()->getSkipValue(static::class, "skip"));
45
        $this->assertSame(false, $this->getSkipChecker()->getSkipValue(static::class, "skipFalse"));
46
        $this->assertSame(1.5, $this->getSkipChecker()->getSkipValue(static::class, "skipFloat"));
47
        $this->assertSame("abc", $this->getSkipChecker()->getSkipValue(static::class, "skipString"));
48
        $array = $this->getSkipChecker()->getSkipValue(static::class, "skipArray");
49
        $this->assertType("iterable", $array);
50
        $this->assertCount(1, $array);
51
    }
52
53
    public function testShouldSkip(): void
54
    {
55
        $this->assertFalsey($this->getSkipChecker()->shouldSkip(static::class, "skipNull"));
56
        $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skip"));
57
        $this->assertFalsey($this->getSkipChecker()->shouldSkip(static::class, "skipFalse"));
58
        $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipInteger"));
59
        $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipFloat"));
60
        $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipString"));
61
        $this->assertTruthy($this->getSkipChecker()->shouldSkip(static::class, "skipArray"));
62
        $this->assertFalsey($this->getSkipChecker()->shouldSkip(static::class, "skipArrayUnknown"));
63
    }
64
65
    private function skipNull(): void
66
    {
67
    }
68
69
    #[Skip()]
70
    private function skip(): void
71
    {
72
    }
73
74
    #[Skip(false)]
75
    private function skipFalse(): void
76
    {
77
    }
78
79
    #[Skip(1)]
80
    private function skipInteger(): void
81
    {
82
    }
83
84
    #[Skip(1.5)]
85
    private function skipFloat(): void
86
    {
87
    }
88
89
    #[Skip("abc")]
90
    private function skipString(): void
91
    {
92
    }
93
94
    #[Skip(["php" => 666])]
95
    private function skipArray(): void
96
    {
97
    }
98
99
    #[Skip(["abc" => "def"])]
100
    private function skipArrayUnknown(): void
101
    {
102
    }
103
}
104