In this answer it mentions using expectOutputString()
to, well, expect output strings in PHPUnit.
I also need to do sort of the counterpart of this, which is to tell a mock to output a string.
I was previously using $mock->will($this->throwException(Exception('foo'))
to have my mock throw an exception but now instead of throwing an exception I need it to log the error and NOT re-throw the exception, which means I need my mock to output a string just as error_log()
does in the method I'm trying to mock, so that my test can expect the string.
Does this make sense? Is it possible to do? Does PHPUnit offer a way to do it?