1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\TestCase; |
4
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\State as State; |
6
|
|
|
use \SimpleSAML\Module\monitor\TestData as TestData; |
7
|
|
|
|
8
|
|
|
class Module extends \SimpleSAML\Module\monitor\TestCaseFactory |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var array |
12
|
|
|
*/ |
13
|
|
|
private $parsed = array(); |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
private $available = array(); |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $module; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var TestData $testData |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
protected function initialize($testData = null) |
31
|
|
|
{ |
32
|
|
|
$this->module = $testData->getInput('required'); |
33
|
|
|
$this->available = $testData->getInput('available'); |
|
|
|
|
34
|
|
|
$this->parsed = explode('|', $this->module); |
35
|
|
|
|
36
|
|
|
parent::initialize($testData); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
protected function invokeTest() |
43
|
|
|
{ |
44
|
|
|
$testResult = new TestResult($this->getCategory(), $this->getModuleName()); |
45
|
|
|
|
46
|
|
|
$state = State::ERROR; |
47
|
|
|
$available = $this->getAvailable(); |
48
|
|
|
|
49
|
|
|
foreach ($this->parsed as $module) { |
50
|
|
|
if (in_array($module, $available)) { |
51
|
|
|
$state = State::OK; |
52
|
|
|
break 1; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
if ($state == State::OK) { |
57
|
|
|
$msg = 'Module loaded'; |
|
|
|
|
58
|
|
|
} else { |
59
|
|
|
$msg = 'Module not loaded'; |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$testResult->setState($state); |
63
|
|
|
$this->setTestResult($state); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return array|null |
68
|
|
|
*/ |
69
|
|
|
private function getAvailable() |
70
|
|
|
{ |
71
|
|
|
assert(is_array($this->available)); |
72
|
|
|
return $this->available; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
private function getModule() |
79
|
|
|
{ |
80
|
|
|
assert(is_string($this->module)); |
81
|
|
|
return $this->module; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getModuleName() |
88
|
|
|
{ |
89
|
|
|
$available = $this->available; |
90
|
|
|
|
91
|
|
|
foreach ($this->parsed as $module) { |
92
|
|
|
if (in_array($module, $available)) { |
93
|
|
|
return $module; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $this->getModule(); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..