1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor; |
4
|
|
|
|
5
|
|
|
final class TestResult |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var string Test category this test belongs to |
9
|
|
|
*/ |
10
|
|
|
private $category; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var string The subject that was tested |
14
|
|
|
*/ |
15
|
|
|
private $subject; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string Message describing the result |
19
|
|
|
*/ |
20
|
|
|
private $message; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var array Data to be used by TestSuite or other TestCases |
24
|
|
|
*/ |
25
|
|
|
private $output; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var State The State object reflecting the result |
29
|
|
|
*/ |
30
|
|
|
private $state = State::NOSTATE; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $category |
34
|
|
|
* @param string $subject |
35
|
|
|
*/ |
36
|
|
|
public function __construct($category = 'Unknown category', $subject = 'Unknown subject') |
37
|
|
|
{ |
38
|
|
|
$this->category = $this->setCategory($category); |
|
|
|
|
39
|
|
|
$this->subject = $this->setSubject($subject); |
|
|
|
|
40
|
|
|
$this->output = setOutput(array()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $subject |
|
|
|
|
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
public function setSubject($value) |
49
|
|
|
{ |
50
|
|
|
assert(is_string($value)); |
51
|
|
|
$this->subject = $value; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getSubject() |
58
|
|
|
{ |
59
|
|
|
assert(is_string($this->subject)); |
60
|
|
|
return $this->subject; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $category |
|
|
|
|
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
public function setCategory($value) |
69
|
|
|
{ |
70
|
|
|
assert(is_string($value)); |
71
|
|
|
$this->category = $value; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
|
|
public function getCategory() |
78
|
|
|
{ |
79
|
|
|
assert(is_string($this->category)); |
80
|
|
|
return $this->category; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $message |
85
|
|
|
* |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
|
|
public function setMessage($message) |
89
|
|
|
{ |
90
|
|
|
assert(is_string($message)); |
91
|
|
|
$this->message = $message; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getMessage() |
98
|
|
|
{ |
99
|
|
|
assert(is_string($this->message)); |
100
|
|
|
return $this->message; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param array $value |
105
|
|
|
* |
106
|
|
|
* @return void |
107
|
|
|
*/ |
108
|
|
|
public function setOutput($value) |
109
|
|
|
{ |
110
|
|
|
assert(is_array($value)); |
111
|
|
|
$this->output = $value; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string|null $key |
116
|
|
|
* |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
|
|
public function getOutput($key = null) |
120
|
|
|
{ |
121
|
|
|
assert(is_array($this->output)); |
122
|
|
|
return is_null($key) ? $this->output : (isSet($this->output[$key]) ? $this->output[$key] : null); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param State $state |
127
|
|
|
* |
128
|
|
|
* @return void |
129
|
|
|
*/ |
130
|
|
|
public function setState($state = State::NOSTATE) |
131
|
|
|
{ |
132
|
|
|
assert($state instanceof State); |
133
|
|
|
$this->state = $state; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return State |
138
|
|
|
*/ |
139
|
|
|
public function getState() |
140
|
|
|
{ |
141
|
|
|
assert($this->state instanceof State); |
142
|
|
|
return $this->state; |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.