From 9257a0a888d92df474485905021f3ef14d31aa34 Mon Sep 17 00:00:00 2001 From: Jon Mahoney Date: Wed, 27 Oct 2021 17:56:23 +0100 Subject: [PATCH] Send, reply, forward tests optional --- README.md | 1 - tests/EmailsTests.php | 12 ++++++++++++ tests/Mailer.php | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2ecaea..11f717b 100644 --- a/README.md +++ b/README.md @@ -316,7 +316,6 @@ The test suite requires the following environment variables to be set: ```sh export MAILOSAUR_API_KEY=your_api_key export MAILOSAUR_SERVER=server_id -export MAILOSAUR_VERIFIED_DOMAIN=server_domain ``` Run all tests: diff --git a/tests/EmailsTests.php b/tests/EmailsTests.php index 533a0d8..11fbe4f 100644 --- a/tests/EmailsTests.php +++ b/tests/EmailsTests.php @@ -248,6 +248,8 @@ public function testAll() public function testCreateSendText() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $subject = "New message"; $options = new MessageCreateOptions($serverName); @@ -264,6 +266,8 @@ public function testCreateSendText() public function testCreateSendHtml() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $subject = "New HTML message"; $options = new MessageCreateOptions($serverName); @@ -280,6 +284,8 @@ public function testCreateSendHtml() public function testForwardText() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $body = "Forwarded message"; $targetEmailId = self::$emails[0]->id; @@ -295,6 +301,8 @@ public function testForwardText() public function testForwardHtml() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $body = "

Forwarded HTML message.

"; $targetEmailId = self::$emails[0]->id; @@ -310,6 +318,8 @@ public function testForwardHtml() public function testReplyText() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $body = "Reply message"; $targetEmailId = self::$emails[0]->id; @@ -324,6 +334,8 @@ public function testReplyText() public function testReplyHtml() { + if (empty(self::$verifiedDomain)) { $this->markTestSkipped(); } + $body = "

Reply HTML message.

"; $targetEmailId = self::$emails[0]->id; diff --git a/tests/Mailer.php b/tests/Mailer.php index 2c56006..a71ce59 100644 --- a/tests/Mailer.php +++ b/tests/Mailer.php @@ -27,7 +27,7 @@ public static function sendEmail(MailosaurClient $client, $server, $sendToAddres )); $randomString = Servers::randomString(); - $verifiedDomain = getenv('MAILOSAUR_VERIFIED_DOMAIN'); + $verifiedDomain = ($vd = getenv('MAILOSAUR_VERIFIED_DOMAIN')) ? $vd : 'mailosaur.net'; $from = join(' ', array($randomString, $randomString, '<' . $randomString . '@' . $verifiedDomain . '>')); $sendToAddress = join(' ', array($randomString, $randomString, '<' . (($sendToAddress === null) ? $client->servers->generateEmailAddress($server) : $sendToAddress) . '>'));