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