diff --git a/.gitignore b/.gitignore
index 778fb078..e27cff1b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,6 @@ phpcs.xml
.phpcs-cache
/.rnd
test/PHPMailerTest.php*nonexistent_file.txt
+test/*/PHPMailerTest.php*nonexistent_file.txt
phpunit.xml
/.phpunit.result.cache
diff --git a/test/PHPMailerLangTest.php b/test/Language/PHPMailerLangTest.php
similarity index 96%
rename from test/PHPMailerLangTest.php
rename to test/Language/PHPMailerLangTest.php
index 3cc08a43..de5af9b0 100644
--- a/test/PHPMailerLangTest.php
+++ b/test/Language/PHPMailerLangTest.php
@@ -12,7 +12,7 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
-namespace PHPMailer\Test;
+namespace PHPMailer\Test\Language;
use PHPMailer\PHPMailer\PHPMailer;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
@@ -48,7 +48,7 @@ final class PHPMailerLangTest extends TestCase
$this->Mail->setLanguage('en');
$definedStrings = $this->Mail->getTranslations();
$err = '';
- foreach (new \DirectoryIterator(__DIR__ . '/../language') as $fileInfo) {
+ foreach (new \DirectoryIterator(__DIR__ . '/../../language') as $fileInfo) {
if ($fileInfo->isDot()) {
continue;
}
diff --git a/test/PHPMailerTest.php b/test/PHPMailer/PHPMailerTest.php
similarity index 90%
rename from test/PHPMailerTest.php
rename to test/PHPMailer/PHPMailerTest.php
index e9c5d614..a340417b 100644
--- a/test/PHPMailerTest.php
+++ b/test/PHPMailer/PHPMailerTest.php
@@ -11,299 +11,20 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
-namespace PHPMailer\Test;
+namespace PHPMailer\Test\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\POP3;
use PHPMailer\PHPMailer\SMTP;
-use Yoast\PHPUnitPolyfills\TestCases\TestCase;
-
-require_once __DIR__ . '/validators.php';
+use PHPMailer\Test\TestCase;
/**
* PHPMailer - PHP email transport unit test class.
*/
final class PHPMailerTest extends TestCase
{
- /**
- * Holds the PHPMailer instance.
- *
- * @var PHPMailer
- */
- private $Mail;
-
- /**
- * Holds the SMTP mail host.
- *
- * @var string
- */
- private $Host = '';
-
- /**
- * Holds the change log.
- *
- * @var string[]
- */
- private $ChangeLog = [];
-
- /**
- * Holds the note log.
- *
- * @var string[]
- */
- private $NoteLog = [];
-
- /**
- * Default include path.
- *
- * @var string
- */
- private $INCLUDE_DIR = '..';
-
- /**
- * PIDs of any processes we need to kill.
- *
- * @var array
- */
- private $pids = [];
-
- /**
- * Run before each test is started.
- */
- protected function set_up()
- {
- $this->INCLUDE_DIR = dirname(__DIR__); //Default to the dir above the test dir, i.e. the project home dir
- if (file_exists($this->INCLUDE_DIR . '/test/testbootstrap.php')) {
- include $this->INCLUDE_DIR . '/test/testbootstrap.php'; //Overrides go in here
- }
- $this->Mail = new PHPMailer();
- $this->Mail->SMTPDebug = SMTP::DEBUG_CONNECTION; //Full debug output
- $this->Mail->Debugoutput = ['PHPMailer\Test\DebugLogTestListener', 'debugLog'];
- $this->Mail->Priority = 3;
- $this->Mail->Encoding = '8bit';
- $this->Mail->CharSet = PHPMailer::CHARSET_ISO88591;
- if (array_key_exists('mail_from', $_REQUEST)) {
- $this->Mail->From = $_REQUEST['mail_from'];
- } else {
- $this->Mail->From = 'unit_test@phpmailer.example.com';
- }
- $this->Mail->FromName = 'Unit Tester';
- $this->Mail->Sender = '';
- $this->Mail->Subject = 'Unit Test';
- $this->Mail->Body = '';
- $this->Mail->AltBody = '';
- $this->Mail->WordWrap = 0;
- if (array_key_exists('mail_host', $_REQUEST)) {
- $this->Mail->Host = $_REQUEST['mail_host'];
- } else {
- $this->Mail->Host = 'mail.example.com';
- }
- if (array_key_exists('mail_port', $_REQUEST)) {
- $this->Mail->Port = $_REQUEST['mail_port'];
- } else {
- $this->Mail->Port = 25;
- }
- $this->Mail->Helo = 'localhost.localdomain';
- $this->Mail->SMTPAuth = false;
- $this->Mail->Username = '';
- $this->Mail->Password = '';
- if (array_key_exists('mail_useauth', $_REQUEST)) {
- $this->Mail->SMTPAuth = $_REQUEST['mail_useauth'];
- }
- if (array_key_exists('mail_username', $_REQUEST)) {
- $this->Mail->Username = $_REQUEST['mail_username'];
- }
- if (array_key_exists('mail_userpass', $_REQUEST)) {
- $this->Mail->Password = $_REQUEST['mail_userpass'];
- }
- $this->Mail->addReplyTo('no_reply@phpmailer.example.com', 'Reply Guy');
- $this->Mail->Sender = 'unit_test@phpmailer.example.com';
- if ($this->Mail->Host != '') {
- $this->Mail->isSMTP();
- } else {
- $this->Mail->isMail();
- }
- if (array_key_exists('mail_to', $_REQUEST)) {
- $this->setAddress($_REQUEST['mail_to'], 'Test User', 'to');
- }
- if (array_key_exists('mail_cc', $_REQUEST) && $_REQUEST['mail_cc'] !== '') {
- $this->setAddress($_REQUEST['mail_cc'], 'Carbon User', 'cc');
- }
- }
-
- /**
- * Run after each test is completed.
- */
- protected function tear_down()
- {
- //Clean global variables
- $this->Mail = null;
- $this->ChangeLog = [];
- $this->NoteLog = [];
-
- foreach ($this->pids as $pid) {
- $p = escapeshellarg($pid);
- shell_exec("ps $p && kill -TERM $p");
- }
- }
-
- /**
- * Build the body of the message in the appropriate format.
- */
- private function buildBody()
- {
- $this->checkChanges();
-
- //Determine line endings for message
- if ('text/html' === $this->Mail->ContentType || $this->Mail->AltBody !== '') {
- $eol = "
\r\n";
- $bullet_start = '