@@ 313-331 (lines=19) @@ | ||
310 | * @param string $nameMethod |
|
311 | * @param string $expectedException |
|
312 | */ |
|
313 | public function callAMethodDescriptorIExpectToGetAnException($nameMethod, $expectedException) |
|
314 | { |
|
315 | $actualException = null; |
|
316 | try { |
|
317 | $descriptor = $this->getLastCreatedDescriptor(); |
|
318 | $r = new \ReflectionObject($descriptor); |
|
319 | ||
320 | if (!$r->hasMethod($nameMethod)) { |
|
321 | $errMsg = "Method {$nameMethod} does not exist"; |
|
322 | throw new \InvalidArgumentException($errMsg); |
|
323 | } |
|
324 | ||
325 | $r->getMethod($nameMethod)->invoke($descriptor); |
|
326 | } catch (\Exception $e) { |
|
327 | $actualException = $e; |
|
328 | } |
|
329 | ||
330 | PHPUnit_Framework_Assert::assertInstanceOf($expectedException, $actualException); |
|
331 | } |
|
332 | ||
333 | /** |
|
334 | * @Then Call a method descriptor :nameMethod. I expect to get an exception message :expectedExceptionMessage |
|
@@ 339-357 (lines=19) @@ | ||
336 | * @param $nameMethod |
|
337 | * @param $expectedExceptionMessage |
|
338 | */ |
|
339 | public function callAMethodDescriptorIExpectToGetAnExceptionMessage($nameMethod, $expectedExceptionMessage) |
|
340 | { |
|
341 | $actualExceptionMessage = null; |
|
342 | try { |
|
343 | $descriptor = $this->getLastCreatedDescriptor(); |
|
344 | $r = new \ReflectionObject($descriptor); |
|
345 | ||
346 | if (!$r->hasMethod($nameMethod)) { |
|
347 | $errMsg = "Method {$nameMethod} does not exist"; |
|
348 | throw new \InvalidArgumentException($errMsg); |
|
349 | } |
|
350 | ||
351 | $r->getMethod($nameMethod)->invoke($descriptor); |
|
352 | } catch (\Exception $e) { |
|
353 | $actualExceptionMessage = $e->getMessage(); |
|
354 | } |
|
355 | ||
356 | PHPUnit_Framework_Assert::assertEquals($expectedExceptionMessage, $actualExceptionMessage); |
|
357 | } |
|
358 | ||
359 | ||
360 |