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