public function testReturnsExpectedVerificationResult()
 {
     $verificationData = ['summary' => 128, 'fingerprint' => 'foo'];
     $this->gnupg->verify('foo', 'bar')->willReturn([$verificationData]);
     $verifier = new GnupgSignatureVerifier($this->gnupg->reveal(), $this->keyservice->reveal());
     $actual = $verifier->verify('foo', 'bar');
     $expected = new GnupgVerificationResult($verificationData);
     $this->assertEquals($expected, $actual);
 }
 /**
  * @param string $message
  * @param string $signature
  *
  * @return GnupgVerificationResult
  * @throws VerificationFailedException
  */
 public function verify($message, $signature)
 {
     try {
         $result = new GnupgVerificationResult($this->gpg->verify($message, $signature)[0]);
         if (!$result->wasVerificationSuccessful() && !$result->isKnownKey()) {
             $this->keyService->importKey($result->getFingerprint(), $this->keyService->downloadKey($result->getFingerprint()));
         }
         return new GnupgVerificationResult($this->gpg->verify($message, $signature)[0]);
     } catch (\Exception $e) {
         throw new VerificationFailedException($e->getMessage(), $e->getCode(), $e);
     }
 }