public function generateAndSend(TwoFactorInterface $user) { $min = pow(10, $this->digits - 1); $max = pow(10, $this->digits) - 1; $code = $this->generateCode($min, $max); $user->setEmailAuthCode($code); $this->persister->persist($user); $this->mailer->sendAuthCode($user); }
/** * @test */ public function generateAndSend_generateNewCode_sendMail() { //Stub the user object $user = $this->getMock("Scheb\\TwoFactorBundle\\Model\\Email\\TwoFactorInterface"); //Mock the mailer $this->mailer->expects($this->once())->method("sendAuthCode")->with($user); $this->authCodeManager->generateAndSend($user); }