I'm trying to stop a method that sends an email from actually sending the email and I think that mock objects (or some variant) are the way to go. Here is the situation:
class UserModel {
public static function resetPassword()
{
// Code to generate new password, etc, etc
self::_sendMail($to, $body);
return 1;
}
private function _sendMail($to, $body)
{
// Send email
}
}
Is there anyway in PHPUnit that I can mock _sendMail() and inject my own code so I can properly test the other logic in resetPassword() ?
My test would simply look something like:
$this->assertTrue(UserModel::resetPassword());
Thanks for any help.