From ca71445fb21490111451b391fbf65d85e56531f7 Mon Sep 17 00:00:00 2001 From: Synchro Date: Thu, 5 Jun 2014 16:58:17 +0200 Subject: [PATCH] Make tests check for config Generate debug output during POP tests Ignore errors during POP3 disconnect Update PHPUnit dependency to 4.1 in composer --- class.pop3.php | 6 +++++- composer.json | 2 +- test/phpmailerTest.php | 25 ++++++++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/class.pop3.php b/class.pop3.php index 431688160..dbc745f14 100644 --- a/class.pop3.php +++ b/class.pop3.php @@ -298,7 +298,11 @@ public function disconnect() $this->sendString('QUIT'); //The QUIT command may cause the daemon to exit, which will kill our connection //So ignore errors here - @fclose($this->pop_conn); + try { + @fclose($this->pop_conn); + } catch (Exception $e) { + //Do nothing + }; } /** diff --git a/composer.json b/composer.json index 6e8880cb3..53d4eb117 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "phpdocumentor/phpdocumentor": "*", - "phpunit/phpunit": "4.0.*" + "phpunit/phpunit": "4.1.*" }, "autoload": { "classmap": ["class.phpmailer.php", "class.pop3.php", "class.smtp.php"] diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php index 01cc88e2a..4d519cb4f 100644 --- a/test/phpmailerTest.php +++ b/test/phpmailerTest.php @@ -291,6 +291,18 @@ public function setAddress($sAddress, $sName = '', $sType = 'to') return false; } + /** + * Check that we have loaded default test params. + * Pretty much everything will fail due to unset recipient if this is not done. + */ + public function testBootstrap() + { + $this->assertTrue( + file_exists('./testbootstrap.php'), + 'Test config params missing - copy testbootstrap.php to testbootstrap-dist.php and change as appropriate' + ); + } + /** * Test CRAM-MD5 authentication * Needs a connection to a server that supports this auth mechanism, so commented out by default @@ -639,9 +651,12 @@ public function testValidate() public function testWordWrap() { $this->Mail->WordWrap = 40; - $my_body = 'Here is the main body of this message. It should ' . - 'be quite a few lines. It should be wrapped at the ' . - '40 characters. Make sure that it is.'; + $my_body = str_repeat( + 'Here is the main body of this message. It should ' . + 'be quite a few lines. It should be wrapped at ' . + '40 characters. Make sure that it is. ', + 10 + ); $nBodyLen = strlen($my_body); $my_body .= "\n\nThis is the above body length: " . $nBodyLen; @@ -1340,7 +1355,7 @@ public function testPopBeforeSmtpGood() sleep(2); //Test a known-good login $this->assertTrue( - POP3::popBeforeSmtp('localhost', 1100, 10, 'user', 'test', 0), + POP3::popBeforeSmtp('localhost', 1100, 10, 'user', 'test', $this->Mail->SMTPDebug), 'POP before SMTP failed' ); //Kill the fake server @@ -1362,7 +1377,7 @@ public function testPopBeforeSmtpBad() sleep(2); //Test a known-bad login $this->assertFalse( - POP3::popBeforeSmtp('localhost', 1101, 10, 'user', 'xxx', 0), + POP3::popBeforeSmtp('localhost', 1101, 10, 'user', 'xxx', $this->Mail->SMTPDebug), 'POP before SMTP should have failed' ); shell_exec('kill -TERM '.escapeshellarg($pid));