1 | <?php |
||
16 | class ExceptionMatcher implements MatcherInterface |
||
17 | { |
||
18 | use MatcherTrait; |
||
19 | |||
20 | /** |
||
21 | * @param string $exceptionType |
||
22 | */ |
||
23 | public function __construct($exceptionType) |
||
27 | |||
28 | /** |
||
29 | * Set arguments to be passed to the callable. |
||
30 | * |
||
31 | * @param array $arguments |
||
32 | * @return $this |
||
33 | */ |
||
34 | public function setArguments(array $arguments) |
||
40 | |||
41 | /** |
||
42 | * Set the expected message of the exception. |
||
43 | * |
||
44 | * @param string $message |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setExpectedMessage($message) |
||
53 | |||
54 | /** |
||
55 | * Set the message thrown from an exception resulting from the |
||
56 | * callable being invoked. |
||
57 | * |
||
58 | * @param string $message |
||
59 | */ |
||
60 | public function setMessage($message) |
||
64 | |||
65 | /** |
||
66 | * Returns the arguments passed to the callable. |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | public function getArguments() |
||
74 | |||
75 | /** |
||
76 | * Return the expected exception message. |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getExpectedMessage() |
||
84 | |||
85 | /** |
||
86 | * Return the message thrown by an exception resulting from the callable |
||
87 | * being invoked. |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function getMessage() |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | * |
||
99 | * If the expected message has been set, the message template will be used. |
||
100 | * |
||
101 | * @return TemplateInterface |
||
102 | */ |
||
103 | public function getTemplate() |
||
115 | |||
116 | /** |
||
117 | * Set the template to be used when an expected exception message is provided. |
||
118 | * |
||
119 | * @param TemplateInterface $template |
||
120 | * @return $this |
||
121 | */ |
||
122 | public function setMessageTemplate(TemplateInterface $template) |
||
128 | |||
129 | /** |
||
130 | * Return a template for rendering exception message templates. |
||
131 | * |
||
132 | * return TemplateInterface |
||
133 | */ |
||
134 | public function getMessageTemplate() |
||
142 | |||
143 | /** |
||
144 | * {@inheritdoc} |
||
145 | * |
||
146 | * @return TemplateInterface |
||
147 | */ |
||
148 | public function getDefaultTemplate() |
||
157 | |||
158 | /** |
||
159 | * Return a default template for exception message assertions. |
||
160 | * |
||
161 | * @return ArrayTemplate |
||
162 | */ |
||
163 | public function getDefaultMessageTemplate() |
||
170 | |||
171 | /** |
||
172 | * Executes the callable and matches the exception type and exception message. |
||
173 | * |
||
174 | * @param $actual |
||
175 | * @return Match |
||
176 | */ |
||
177 | public function match($actual) |
||
186 | |||
187 | /** |
||
188 | * Validate that expected is indeed a valid callable. |
||
189 | * |
||
190 | * @throws \BadFunctionCallException |
||
191 | */ |
||
192 | protected function validateCallable($callable) |
||
199 | |||
200 | private function callableException($callable) |
||
217 | |||
218 | private function matchMessage($actual, $exception, $message) |
||
228 | |||
229 | private function matchType($actual, $exception) |
||
236 | |||
237 | /** |
||
238 | * @var array |
||
239 | */ |
||
240 | protected $arguments = []; |
||
241 | |||
242 | /** |
||
243 | * @var string |
||
244 | */ |
||
245 | protected $expectedMessage = ''; |
||
246 | |||
247 | /** |
||
248 | * A captured exception message. |
||
249 | * |
||
250 | * @var string |
||
251 | */ |
||
252 | protected $message; |
||
253 | |||
254 | /** |
||
255 | * @var TemplateInterface |
||
256 | */ |
||
257 | protected $messageTemplate; |
||
258 | } |
||
259 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.