Skip to content

Commit

Permalink
Make tests check for config
Browse files Browse the repository at this point in the history
Generate debug output during POP tests
Ignore errors during POP3 disconnect
Update PHPUnit dependency to 4.1 in composer
  • Loading branch information
Synchro committed Jun 5, 2014
1 parent 6d5a4e9 commit ca71445
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion class.pop3.php
Expand Up @@ -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
};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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"]
Expand Down
25 changes: 20 additions & 5 deletions test/phpmailerTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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));
Expand Down

0 comments on commit ca71445

Please sign in to comment.