From 35e76a2fa8faf8212248a7511605b23f46b51eb9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 12 Jul 2021 01:29:56 +0200 Subject: [PATCH] ReplyToGetSetClearTest: improve "extensions not available" test The "fakefunctions" are all nice and dandy to get past the `idnSupported()` check, but if either of these functions is not _really_ available, the actual behaviour of the `PHPMailer::addReplyTo()` function is to _fail_ (on the address validation call in `PHPMailer::addAnAddress()`) and return `false`. In other words, this test was nonsensical as it tested for something which can, and should, never happen. With this in mind, the test has been rewritten to reflect the *real* behaviour when either Mbstring or the `idn_to_ascii` function is not available. --- test/PHPMailer/ReplyToGetSetClearTest.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/PHPMailer/ReplyToGetSetClearTest.php b/test/PHPMailer/ReplyToGetSetClearTest.php index 7e9ca7fd..db79dc2c 100644 --- a/test/PHPMailer/ReplyToGetSetClearTest.php +++ b/test/PHPMailer/ReplyToGetSetClearTest.php @@ -400,13 +400,19 @@ final class ReplyToGetSetClearTest extends PreSendTestCase ); } - public function testGivenIdnAddress_addReplyTo_returns_true() + /** + * Test unsuccesfully adding an Reply-to address when an email address containing + * an 8bit character is passed and either the MbString or the Intl extension are + * not available. + * + * @covers \PHPMailer\PHPMailer\PHPMailer::addAnAddress + */ + public function testAddReplyToFailsOn8BitCharInDomainWithoutOptionalExtensions() { - if (file_exists(\PHPMAILER_INCLUDE_DIR . '/test/fakefunctions.php') === false) { - $this->markTestSkipped('/test/fakefunctions.php file not found'); + if (extension_loaded('mbstring') && function_exists('idn_to_ascii')) { + $this->markTestSkipped('Test requires MbString and/or Intl *not* to be available'); } - include \PHPMAILER_INCLUDE_DIR . '/test/fakefunctions.php'; - $this->assertTrue($this->Mail->addReplyTo('test@françois.ch')); + self::assertFalse($this->Mail->addReplyTo('test@françois.ch')); } }