/**
  * @test
  * @group sms
  */
 public function a_successful_result_has_a_second_factor_id()
 {
     // generated once using \Rhumsaa\Uuid\Uuid::uuid4()
     $uuidv4 = 'ba6d20b7-2b9c-494a-926b-d355187b2ddb';
     $result = ProofOfPossessionResult::secondFactorCreated($uuidv4);
     $this->assertTrue($result->isSuccessful());
     $this->assertEquals($uuidv4, $result->getSecondFactorId(), 'The given UUID should be returned upon request');
     $this->assertFalse($result->didProofOfPossessionFail());
     $this->assertFalse($result->hasChallengeExpired());
     $this->assertFalse($result->wasIncorrectChallengeResponseGiven());
 }
 /**
  * @param VerifySmsChallengeCommand $challengeCommand
  * @return ProofOfPossessionResult
  */
 public function provePossession(VerifySmsChallengeCommand $challengeCommand)
 {
     $stepupCommand = new VerifyPossessionOfPhoneCommand();
     $stepupCommand->challenge = $challengeCommand->challenge;
     $verification = $this->smsSecondFactorService->verifyPossession($stepupCommand);
     if ($verification->didOtpExpire()) {
         return ProofOfPossessionResult::challengeExpired();
     } elseif ($verification->wasAttemptedTooManyTimes()) {
         return ProofOfPossessionResult::tooManyAttempts();
     } elseif (!$verification->wasSuccessful()) {
         return ProofOfPossessionResult::incorrectChallenge();
     }
     $command = new ProvePhonePossessionCommand();
     $command->identityId = $challengeCommand->identity;
     $command->secondFactorId = Uuid::generate();
     $command->phoneNumber = $verification->getPhoneNumber();
     $result = $this->commandService->execute($command);
     if (!$result->isSuccessful()) {
         return ProofOfPossessionResult::proofOfPossessionCommandFailed();
     }
     return ProofOfPossessionResult::secondFactorCreated($command->secondFactorId);
 }