/**
* @covers GPGMailer::decrypt()
* @covers GPGMailer::encrypt()
*/
public function testEncryptedMessage()
{
// First, create a Zend\Mail message as usual:
$plaintext = 'Cleartext for now. Do not worry; this gets encrypted. Don\' actually send this, however.';
$plaintext .= \random_bytes(32);
$message = new Message();
$message->addTo('*****@*****.**', 'GPGMailer Test Email');
$message->setBody($plaintext);
// Instantiate GPGMailer:
$gpgMailer = new GPGMailer(new File(), ['homedir' => '~']);
$publicKey = file_get_contents(__DIR__ . '/public.key');
$fingerprint = $gpgMailer->import($publicKey);
$encrypted = $gpgMailer->encrypt($message, $fingerprint);
$body = $encrypted->getBodyText();
$this->assertTrue(\strpos($body, '-----BEGIN PGP MESSAGE-----') !== false);
$privateKey = file_get_contents(__DIR__ . '/private.key');
$gpgMailer->setPrivateKey($privateKey);
$decrypted = $gpgMailer->decrypt($encrypted);
$this->assertSame($plaintext, $decrypted->getBodyText());
}