forked from PHPMailer/PHPMailer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Windows compatibility for tests
- Loading branch information
Showing
1 changed file
with
28 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License | ||
*/ | ||
|
||
require_once '../PHPMailerAutoload.php'; | ||
require_once realpath('../PHPMailerAutoload.php'); | ||
|
||
/** | ||
* PHPMailer - PHP email transport unit test class | ||
|
@@ -49,26 +49,26 @@ class PHPMailerTest extends PHPUnit_Framework_TestCase | |
*/ | ||
public $NoteLog = array(); | ||
|
||
/** | ||
* Default include path | ||
* @var string | ||
*/ | ||
public $INCLUDE_DIR = '../'; | ||
|
||
/** | ||
* PIDs of any processes we need to kill | ||
* @var array | ||
* @access private | ||
*/ | ||
private $pids = array(); | ||
|
||
/** | ||
* Default include path | ||
* @var string | ||
*/ | ||
const INCLUDE_DIR = '../'; | ||
|
||
/** | ||
* Run before each test is started. | ||
*/ | ||
public function setUp() | ||
{ | ||
if (file_exists('./testbootstrap.php')) { | ||
include './testbootstrap.php'; //Overrides go in here | ||
if (file_exists('testbootstrap.php')) { | ||
include 'testbootstrap.php'; //Overrides go in here | ||
} | ||
$this->Mail = new PHPMailer; | ||
$this->Mail->SMTPDebug = 3; //Full debug output | ||
|
@@ -100,7 +100,6 @@ public function setUp() | |
$this->Mail->SMTPAuth = false; | ||
$this->Mail->Username = ''; | ||
$this->Mail->Password = ''; | ||
$this->Mail->PluginDir = $this->INCLUDE_DIR; | ||
$this->Mail->addReplyTo('[email protected]', 'Reply Guy'); | ||
$this->Mail->Sender = '[email protected]'; | ||
if (strlen($this->Mail->Host) > 0) { | ||
|
@@ -300,7 +299,7 @@ public function setAddress($sAddress, $sName = '', $sType = 'to') | |
public function testBootstrap() | ||
{ | ||
$this->assertTrue( | ||
file_exists('./testbootstrap.php'), | ||
file_exists('testbootstrap.php'), | ||
'Test config params missing - copy testbootstrap.php to testbootstrap-dist.php and change as appropriate' | ||
); | ||
} | ||
|
@@ -725,7 +724,7 @@ public function testMultiplePlainFileAttachment() | |
$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(realpath(self::INCLUDE_DIR . 'examples/images/phpmailer.png'))) { | ||
$this->assertTrue(false, $this->Mail->ErrorInfo); | ||
return; | ||
} | ||
|
@@ -831,7 +830,7 @@ public function testHtmlIso8859() | |
|
||
//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(realpath('../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! | ||
|
@@ -841,7 +840,7 @@ public function testHtmlIso8859() | |
"ISO-8859-1", | ||
mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true) | ||
), | ||
'../examples' | ||
realpath(self::INCLUDE_DIR . 'examples') | ||
); | ||
$this->buildBody(); | ||
$this->assertTrue( | ||
|
@@ -905,7 +904,7 @@ public function testUtf8WithEmbeddedImage() | |
</html> | ||
EOT; | ||
$this->Mail->addEmbeddedImage( | ||
'../examples/images/phpmailer.png', | ||
realpath(self::INCLUDE_DIR . 'examples/images/phpmailer.png'), | ||
'my-attach', | ||
'phpmailer.png', | ||
'base64', | ||
|
@@ -941,12 +940,12 @@ public function testPlainUtf8() | |
*/ | ||
public function testMsgHTML() | ||
{ | ||
$message = file_get_contents('../examples/contentsutf8.html'); | ||
$message = file_get_contents(realpath(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, realpath(self::INCLUDE_DIR . 'examples')); | ||
$this->Mail->Subject .= ': msgHTML'; | ||
|
||
$this->assertNotEmpty($this->Mail->Body, 'Body not set by msgHTML'); | ||
|
@@ -955,7 +954,7 @@ public function testMsgHTML() | |
|
||
//Again, using a custom HTML to text converter | ||
$this->Mail->AltBody = ''; | ||
$this->Mail->msgHTML($message, '../examples', function ($html) { | ||
$this->Mail->msgHTML($message, realpath(self::INCLUDE_DIR . 'examples'), function ($html) { | ||
return strtoupper(strip_tags($html)); | ||
}); | ||
$this->Mail->Subject .= ' + custom html2text'; | ||
|
@@ -973,7 +972,9 @@ public function testHTMLAttachment() | |
$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( | ||
realpath(self::INCLUDE_DIR . 'examples/images/phpmailer_mini.png'), 'phpmailer_mini.png') | ||
) { | ||
$this->assertTrue(false, $this->Mail->ErrorInfo); | ||
return; | ||
} | ||
|
@@ -995,7 +996,7 @@ public function testHTMLStringEmbedNoName() | |
$this->Mail->isHTML(true); | ||
|
||
if (!$this->Mail->addStringEmbeddedImage( | ||
file_get_contents('../examples/images/phpmailer_mini.png'), | ||
file_get_contents(realpath(self::INCLUDE_DIR . 'examples/images/phpmailer_mini.png')), | ||
md5('phpmailer_mini.png').'@phpmailer.0', | ||
'', //intentionally empty name | ||
'base64', | ||
|
@@ -1019,12 +1020,12 @@ public function testHTMLMultiAttachment() | |
$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(realpath(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(realpath(self::INCLUDE_DIR . 'examples/images/phpmailer.png'), 'phpmailer.png')) { | ||
$this->assertTrue(false, $this->Mail->ErrorInfo); | ||
return; | ||
} | ||
|
@@ -1044,7 +1045,7 @@ public function testEmbeddedImage() | |
$this->Mail->isHTML(true); | ||
|
||
if (!$this->Mail->addEmbeddedImage( | ||
'../examples/images/phpmailer.png', | ||
realpath(self::INCLUDE_DIR . 'examples/images/phpmailer.png'), | ||
'my-attach', | ||
'phpmailer.png', | ||
'base64', | ||
|
@@ -1073,7 +1074,7 @@ public function testMultiEmbeddedImage() | |
$this->Mail->isHTML(true); | ||
|
||
if (!$this->Mail->addEmbeddedImage( | ||
'../examples/images/phpmailer.png', | ||
realpath(self::INCLUDE_DIR . 'examples/images/phpmailer.png'), | ||
'my-attach', | ||
'phpmailer.png', | ||
'base64', | ||
|
@@ -1135,7 +1136,7 @@ public function testAltBodyAttachment() | |
public function testIcal() | ||
{ | ||
//Standalone ICS tests | ||
require_once '../extras/EasyPeasyICS.php'; | ||
require_once realpath(self::INCLUDE_DIR . 'extras/EasyPeasyICS.php'); | ||
$ICS = new EasyPeasyICS("PHPMailer test calendar"); | ||
$this->assertNotEmpty( | ||
$ICS->addEvent( | ||
|
@@ -2027,8 +2028,8 @@ public function testPopBeforeSmtpGood() | |
} | ||
|
||
/** | ||
* Use a fake POP3 server to test POP-before-SMTP auth. | ||
* With a known-bad login | ||
* Use a fake POP3 server to test POP-before-SMTP auth | ||
* with a known-bad login. | ||
*/ | ||
public function testPopBeforeSmtpBad() | ||
{ | ||
|