mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-20 10:02:14 +02:00
PHPUnit tweaks
This commit is contained in:
parent
2b632a71be
commit
6bcb0f8f8d
@ -50,7 +50,7 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
|
||||
* Default include path
|
||||
* @var string
|
||||
*/
|
||||
public $INCLUDE_DIR = '../';
|
||||
const INCLUDE_DIR = __DIR__;
|
||||
|
||||
/**
|
||||
* PIDs of any processes we need to kill
|
||||
@ -723,7 +723,7 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->Mail->Body = 'Here is the text body';
|
||||
$this->Mail->Subject .= ': Plain + Multiple FileAttachments';
|
||||
|
||||
if (!$this->Mail->addAttachment('../examples/images/phpmailer.png')) {
|
||||
if (!$this->Mail->addAttachment(self::INCLUDE_DIR.'examples/images/phpmailer.png')) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
@ -824,7 +824,7 @@ EOT;
|
||||
|
||||
//This file is in ISO-8859-1 charset
|
||||
//Needs to be external because this file is in UTF-8
|
||||
$content = file_get_contents('../examples/contents.html');
|
||||
$content = file_get_contents(self::INCLUDE_DIR.'examples/contents.html');
|
||||
// This is the string 'éèîüçÅñæß' in ISO-8859-1, base-64 encoded
|
||||
$check = base64_decode('6eju/OfF8ebf');
|
||||
//Make sure it really is in ISO-8859-1!
|
||||
@ -834,7 +834,7 @@ EOT;
|
||||
"ISO-8859-1",
|
||||
mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true)
|
||||
),
|
||||
'../examples'
|
||||
self::INCLUDE_DIR.'examples'
|
||||
);
|
||||
$this->buildBody();
|
||||
$this->assertTrue(
|
||||
@ -898,7 +898,7 @@ EOT;
|
||||
</html>
|
||||
EOT;
|
||||
$this->Mail->addEmbeddedImage(
|
||||
'../examples/images/phpmailer.png',
|
||||
self::INCLUDE_DIR .'examples/images/phpmailer.png',
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
@ -934,12 +934,12 @@ EOT;
|
||||
*/
|
||||
public function testMsgHTML()
|
||||
{
|
||||
$message = file_get_contents('../examples/contentsutf8.html');
|
||||
$message = file_get_contents(self::INCLUDE_DIR .'examples/contentsutf8.html');
|
||||
$this->Mail->CharSet = 'utf-8';
|
||||
$this->Mail->Body = '';
|
||||
$this->Mail->AltBody = '';
|
||||
//Uses internal HTML to text conversion
|
||||
$this->Mail->msgHTML($message, '../examples');
|
||||
$this->Mail->msgHTML($message, self::INCLUDE_DIR .'examples');
|
||||
$this->Mail->Subject .= ': msgHTML';
|
||||
|
||||
$this->assertNotEmpty($this->Mail->Body, 'Body not set by msgHTML');
|
||||
@ -948,9 +948,13 @@ EOT;
|
||||
|
||||
//Again, using a custom HTML to text converter
|
||||
$this->Mail->AltBody = '';
|
||||
$this->Mail->msgHTML($message, '../examples', function ($html) {
|
||||
return strtoupper(strip_tags($html));
|
||||
});
|
||||
$this->Mail->msgHTML(
|
||||
$message,
|
||||
self::INCLUDE_DIR .'examples',
|
||||
function ($html) {
|
||||
return strtoupper(strip_tags($html));
|
||||
}
|
||||
);
|
||||
$this->Mail->Subject .= ' + custom html2text';
|
||||
$this->assertNotEmpty($this->Mail->AltBody, 'Custom AltBody not set by msgHTML');
|
||||
|
||||
@ -966,7 +970,11 @@ EOT;
|
||||
$this->Mail->Subject .= ': HTML + Attachment';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addAttachment('../examples/images/phpmailer_mini.png', 'phpmailer_mini.png')) {
|
||||
if (!$this->Mail->addAttachment(
|
||||
self::INCLUDE_DIR . 'examples/images/phpmailer_mini.png',
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
@ -988,7 +996,7 @@ EOT;
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addStringEmbeddedImage(
|
||||
file_get_contents('../examples/images/phpmailer_mini.png'),
|
||||
file_get_contents(self::INCLUDE_DIR .'examples/images/phpmailer_mini.png'),
|
||||
md5('phpmailer_mini.png').'@phpmailer.0',
|
||||
'', //intentionally empty name
|
||||
'base64',
|
||||
@ -1012,12 +1020,16 @@ EOT;
|
||||
$this->Mail->Subject .= ': HTML + multiple Attachment';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addAttachment('../examples/images/phpmailer_mini.png', 'phpmailer_mini.png')) {
|
||||
if (!$this->Mail->addAttachment(
|
||||
self::INCLUDE_DIR . 'examples/images/phpmailer_mini.png',
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->Mail->addAttachment('../examples/images/phpmailer.png', 'phpmailer.png')) {
|
||||
if (!$this->Mail->addAttachment(self::INCLUDE_DIR .'examples/images/phpmailer.png', 'phpmailer.png')) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
@ -1037,7 +1049,7 @@ EOT;
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
'../examples/images/phpmailer.png',
|
||||
self::INCLUDE_DIR .'examples/images/phpmailer.png',
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
@ -1066,7 +1078,7 @@ EOT;
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
'../examples/images/phpmailer.png',
|
||||
self::INCLUDE_DIR .'examples/images/phpmailer.png',
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
|
Loading…
Reference in New Issue
Block a user