I am trying to stop the method that sends an email from actually sending the email, and I think that mock objects (or some options) are the way to go. Here is the situation:
class UserModel {
public static function resetPassword()
{
self::_sendMail($to, $body);
return 1;
}
private function _sendMail($to, $body)
{
}
}
Is there any way in PHPUnit that I can mock _sendMail () and enter my own code so that I can correctly test other logic in resetPassword ()?
My test will look something like this:
$this->assertTrue(UserModel::resetPassword());
Thanks for any help.
source
share