vendredi 27 février 2015

PHPunit to test catch block

I have a code like this one:



public function one()
{
try {
$this->two();
} catch (Exception $E) {
$this->three();
}
}


How can i test that $this->three() function is called?


I've tried to "mock by code" $this->two() and throw error instead of it's original code, but that ends up with error caught by phpunit itself.


Tried setExpectedException, but it also doesn't solve the problem - catch runs inside phpunit again and just ignored.


Function $this->three() never called in both cases.


Thanks!


Aucun commentaire:

Enregistrer un commentaire