| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
namespace Tests\fixtures; |
| 14 |
|
| 15 |
use PHPUnit\Framework\TestCase; |
| 16 |
use Webklex\PHPIMAP\ClientManager; |
| 17 |
use Webklex\PHPIMAP\Config; |
| 18 |
use Webklex\PHPIMAP\Exceptions\AuthFailedException; |
| 19 |
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException; |
| 20 |
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException; |
| 21 |
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException; |
| 22 |
use Webklex\PHPIMAP\Exceptions\InvalidMessageDateException; |
| 23 |
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException; |
| 24 |
use Webklex\PHPIMAP\Exceptions\MessageContentFetchingException; |
| 25 |
use Webklex\PHPIMAP\Exceptions\ResponseException; |
| 26 |
use Webklex\PHPIMAP\Exceptions\RuntimeException; |
| 27 |
use Webklex\PHPIMAP\Message; |
| 28 |
use \ReflectionException; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
abstract class FixtureTestCase extends TestCase { |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
protected static ClientManager $manager; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
final public function __construct(?string $name = null, array $data = [], $dataName = '') { |
| 50 |
parent::__construct($name, $data, $dataName); |
| 51 |
|
| 52 |
self::$manager = new ClientManager([ |
| 53 |
'options' => [ |
| 54 |
"debug" => $_ENV["LIVE_MAILBOX_DEBUG"] ?? false, |
| 55 |
], |
| 56 |
'accounts' => [ |
| 57 |
'default' => [ |
| 58 |
'host' => getenv("LIVE_MAILBOX_HOST"), |
| 59 |
'port' => getenv("LIVE_MAILBOX_PORT"), |
| 60 |
'encryption' => getenv("LIVE_MAILBOX_ENCRYPTION"), |
| 61 |
'validate_cert' => getenv("LIVE_MAILBOX_VALIDATE_CERT"), |
| 62 |
'username' => getenv("LIVE_MAILBOX_USERNAME"), |
| 63 |
'password' => getenv("LIVE_MAILBOX_PASSWORD"), |
| 64 |
'protocol' => 'imap', |
| 65 |
], |
| 66 |
], |
| 67 |
]); |
| 68 |
return self::$manager; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
final public function getFixture(string $template, ?Config $config = null) : Message { |
| 88 |
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", $template]); |
| 89 |
$message = Message::fromFile($filename, $config); |
| 90 |
self::assertInstanceOf(Message::class, $message); |
| 91 |
|
| 92 |
return $message; |
| 93 |
} |
| 94 |
} |