|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\TestSuite\Modules; |
|
4
|
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\State as State; |
|
6
|
|
|
use \SimpleSAML\Module\monitor\TestCase as TestCase; |
|
7
|
|
|
use \SimpleSAML\Module\monitor\TestData as TestData; |
|
8
|
|
|
|
|
9
|
|
|
final class ModuleSet extends \SimpleSAML\Module\monitor\TestSuiteFactory |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var array |
|
13
|
|
|
*/ |
|
14
|
|
|
private $required = array(); |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var array |
|
18
|
|
|
*/ |
|
19
|
|
|
private $available = array(); |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
private $dependencies = array(); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
private $type; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var TestCase |
|
33
|
|
|
*/ |
|
34
|
|
|
private $testCase; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param TestData $testData |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function initialize($testData) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->required = $testData->getInput('required'); |
|
|
|
|
|
|
44
|
|
|
$this->available = $testData->getInput('available'); |
|
|
|
|
|
|
45
|
|
|
$this->dependencies = $testData->getInput('dependencies'); |
|
|
|
|
|
|
46
|
|
|
$this->type = $testData->getInput('type'); |
|
47
|
|
|
$this->testCase = $testData->getInput('testCase'); |
|
48
|
|
|
} |
|
49
|
|
|
/** |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function invokeTestSuite() |
|
53
|
|
|
{ |
|
54
|
|
|
$testResult = new TestResult($this->type, implode(', ', $this->required)); |
|
55
|
|
|
if (is_null($this->available)) { |
|
56
|
|
|
$testResult->setState(State::SKIPPED); |
|
57
|
|
|
$testResult->setMessage('Unable to verify installed modules'); |
|
58
|
|
|
$this->addTestResult($testResult); |
|
59
|
|
|
} else { |
|
60
|
|
|
foreach ($this->required as $module) { |
|
61
|
|
|
$testData = new TestData([ |
|
62
|
|
|
'required' => $module, |
|
63
|
|
|
'available' => $this->available |
|
64
|
|
|
]); |
|
65
|
|
|
|
|
66
|
|
|
$moduleTest = new $this->testCase($this, $testData); |
|
67
|
|
|
$moduleTestResult = $moduleTest->getTestResult(); |
|
68
|
|
|
if ($moduleTestResult->getState() != State::OK) { |
|
69
|
|
|
$missing = array(); |
|
70
|
|
|
while ($dependency = array_search($this->required, $this->dependencies)) { |
|
71
|
|
|
if (\SimpleSAML\Module::isModuleEnabled($dependency)) { |
|
72
|
|
|
$missing[] = $dependency; |
|
73
|
|
|
} |
|
74
|
|
|
unset($dependencies[$dependency]); |
|
75
|
|
|
} |
|
76
|
|
|
if (!empty($missing)) { |
|
77
|
|
|
$moduleTestResult->setSubject($moduleTest->getModuleName()); |
|
78
|
|
|
$moduleTestResult->setMessage('Module not loaded; dependency for ' . implode(', ', $missing)); |
|
79
|
|
|
} |
|
80
|
|
|
$this->addTestResult($moduleTestResult); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
$this->calculateState(); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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..