|
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
|
|
|
|