PHP Classes

File: tests/GPGMailerTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   PHP GPG Email Encrypt   tests/GPGMailerTest.php   Download  
File: tests/GPGMailerTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP GPG Email Encrypt
Encrypt, decrypt and sign email messages with GPG
Author: By
Last change: Update to Laminas
Date: 3 years ago
Size: 1,309 bytes
 

Contents

Class file image Download
<?php

use Laminas\Mail\Transport\File;
use
ParagonIE\GPGMailer\GPGMailer;
use
ParagonIE\GPGMailer\GPGMailerException;
use
PHPUnit\Framework\TestCase;

/**
 * Class GPGMailerTest
 */
class GPGMailerTest extends TestCase
{
   
/**
     * @var GPGMailer
     */
   
private $gm;

   
/**
     * @throws GPGMailerException
     */
   
public function setUp(): void
   
{
        if (\
is_dir(__DIR__ . '/test/')) {
            \
rmdir(__DIR__ . '/test/');
        }
       
$this->gm = new GPGMailer(
            new
File(),
            [
'homedir' => '~']
        );
    }

   
/**
     * @throws GPGMailerException
     */
   
public function testSetOption()
    {
       
$gm = clone $this->gm;
       
$gm->setOption('invalid key', true);
       
$this->assertTrue($gm->getOption('invalid key'));

        \
mkdir(__DIR__ . '/test/', 0400);
        if (
is_writable(__DIR__ . '/test/')) {
           
$this->markTestSkipped('Inside virtualbox shared folder.');
        }
        try {
           
$gm->setOption('homedir', __DIR__ . '/test/');
           
$this->fail('No exception thrown');
        } catch (
GPGMailerException $ex) {
        }
        \
rmdir(__DIR__ . '/test/');

       
$this->assertSame(
            [
'homedir' => '~', 'invalid key' => true],
           
$gm->getOptions()
        );
    }
}