I'm trying to catch exceptions with my spec but i can't make it works. This is my code:
$this->edit('updated comment', $comment, $user)
->shouldReturnAnInstanceOf('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException');
What i'm doing wrong?
According to documentation, you can do something like this using Matcher
for testing exceptions:
$this
->shouldThrow('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException')
->during('edit', array('updated comment', $comment, $user));
You can also take a look into cookbook which is in phpspec repository on Github.