1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\monitor; |
6
|
|
|
|
7
|
|
|
use function is_null; |
8
|
|
|
|
9
|
|
|
abstract class TestCaseFactory implements TestInterface |
10
|
|
|
{ |
11
|
|
|
/** @var string */ |
12
|
|
|
private string $category; |
13
|
|
|
|
14
|
|
|
/** @var string */ |
15
|
|
|
private string $subject; |
16
|
|
|
|
17
|
|
|
/** @var \SimpleSAML\Module\monitor\TestData */ |
18
|
|
|
private TestData $testData; |
19
|
|
|
|
20
|
|
|
/** @var \SimpleSAML\Module\monitor\TestResult */ |
21
|
|
|
private TestResult $testResult; |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param \SimpleSAML\Module\monitor\TestData|null $testData |
26
|
|
|
*/ |
27
|
|
|
public function __construct(TestData $testData = null) |
28
|
|
|
{ |
29
|
|
|
if (is_null($testData)) { |
30
|
|
|
$testData = new TestData([]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$this->initialize($testData); |
34
|
|
|
$this->invokeTest(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param \SimpleSAML\Module\monitor\TestData $testData |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
protected function initialize(TestData $testData): void |
44
|
|
|
{ |
45
|
|
|
$this->setTestData($testData); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string $category |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
protected function setCategory(string $category): void |
55
|
|
|
{ |
56
|
|
|
$this->category = $category; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getCategory(): string |
64
|
|
|
{ |
65
|
|
|
return $this->category; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \SimpleSAML\Module\monitor\TestData |
71
|
|
|
*/ |
72
|
|
|
public function getTestData(): TestData |
73
|
|
|
{ |
74
|
|
|
return $this->testData; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param \SimpleSAML\Module\monitor\TestData $testData |
80
|
|
|
* |
81
|
|
|
* @return void |
82
|
|
|
*/ |
83
|
|
|
protected function setTestData(TestData $testData): void |
84
|
|
|
{ |
85
|
|
|
$this->testData = $testData; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param \SimpleSAML\Module\monitor\TestResult $testResult |
91
|
|
|
* |
92
|
|
|
* @return void |
93
|
|
|
*/ |
94
|
|
|
protected function setTestResult(TestResult $testResult): void |
95
|
|
|
{ |
96
|
|
|
$this->testResult = $testResult; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return \SimpleSAML\Module\monitor\TestResult |
102
|
|
|
*/ |
103
|
|
|
public function getTestResult(): TestResult |
104
|
|
|
{ |
105
|
|
|
return $this->testResult; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param string $subject |
111
|
|
|
* |
112
|
|
|
* @return void |
113
|
|
|
*/ |
114
|
|
|
protected function setSubject(string $subject): void |
115
|
|
|
{ |
116
|
|
|
$this->subject = $subject; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getSubject(): string |
124
|
|
|
{ |
125
|
|
|
return $this->subject; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
abstract public function invokeTest(): void; |
129
|
|
|
} |
130
|
|
|
|