public function beginAuthentication(AuthenticationContextInterface $context) { // Check if user can do email authentication $user = $context->getUser(); if ($user instanceof TwoFactorInterface && $user->isEmailAuthEnabled()) { // Generate and send a new security code $this->codeGenerator->generateAndSend($user); return true; } return false; }
/** * @test */ public function beginAuthentication_interfaceNotImplemented_returnFalse() { $user = new \stdClass(); //Any class without TwoFactorInterface $context = $this->getAuthenticationContext($user); $returnValue = $this->provider->beginAuthentication($context); $this->assertFalse($returnValue); }