/** * @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); }
/** * @test */ public function generateAndSend_useOriginalCodeGenerator_codeBetweenRange() { //Mock the user object $user = $this->createMock('Scheb\\TwoFactorBundle\\Model\\Email\\TwoFactorInterface'); $user->expects($this->once())->method('setEmailAuthCode')->with($this->logicalAnd($this->greaterThanOrEqual(10000), $this->lessThanOrEqual(99999))); //Construct test subject with original class $authCodeManager = new CodeGenerator($this->persister, $this->mailer, 5); $authCodeManager->generateAndSend($user); }