-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
827e653
commit 0ace2c1
Showing
1 changed file
with
52 additions
and
14 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 |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
use PHPUnit\Framework\TestCase; | ||
use PopArtDesign\WordPressMailerDSN\PHPMailerConfigurator; | ||
|
||
|
||
/** | ||
* @covers PHPMailerConfigurator | ||
* @runTestsInSeparateProcesses | ||
|
@@ -47,19 +46,6 @@ public function testConfiguresUsingMailerDsnConstant() | |
$this->assertEquals('/usr/sbin/sendmail -oi -t', $mailer->Sendmail); | ||
} | ||
|
||
public function testGivesPreferenceToEnvsOverConstants() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
$mailer = new PHPMailer(); | ||
|
||
$_SERVER['MAILER_DSN'] = 'smtps://pop:[email protected]:587?SMTPDebug=3&Timeout=1000'; | ||
define('MAILER_DSN', 'sendmail://localhost?Sendmail=/usr/sbin/sendmail%20-oi%20-t'); | ||
|
||
$configurator->configure($mailer); | ||
|
||
$this->assertEquals('smtp', $mailer->Mailer); | ||
} | ||
|
||
public function testConfiguresDebugUsingEnvs() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
|
@@ -129,4 +115,56 @@ public function testConfiguresDkimDomainAndIdentityWithDefaultValues() | |
$this->assertEquals('[email protected]', $mailer->DKIM_identity); | ||
$this->assertEquals('popartdesign.ru', $mailer->DKIM_domain); | ||
} | ||
|
||
public function testGivesPreferenceToEnvsOverConstants() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
$mailer = new PHPMailer(); | ||
|
||
$_SERVER['MAILER_DSN'] = 'smtps://pop:[email protected]:587?SMTPDebug=3&Timeout=1000'; | ||
define('MAILER_DSN', 'sendmail://localhost?Sendmail=/usr/sbin/sendmail%20-oi%20-t'); | ||
|
||
$configurator->configure($mailer); | ||
|
||
$this->assertEquals('smtp', $mailer->Mailer); | ||
} | ||
|
||
public function testGivesPreferenceToServerSuperglobalOverEnvAndGetenv() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
$mailer = new PHPMailer(); | ||
|
||
$_SERVER['MAILER_DEBUG'] = 1; | ||
$_ENV['MAILER_DEBUG'] = 2; | ||
putenv('MAILER_DEBUG=3'); | ||
|
||
$configurator->configure($mailer); | ||
|
||
$this->assertEquals(1, $mailer->SMTPDebug); | ||
} | ||
|
||
public function testUsesEnvSuperglobalIfServerIsNotSet() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
$mailer = new PHPMailer(); | ||
|
||
$_ENV['MAILER_DEBUG'] = 1; | ||
putenv('MAILER_DEBUG=2'); | ||
|
||
$configurator->configure($mailer); | ||
|
||
$this->assertEquals(1, $mailer->SMTPDebug); | ||
} | ||
|
||
public function testUsesGetenvAsFallback() | ||
{ | ||
$configurator = new PHPMailerConfigurator(); | ||
$mailer = new PHPMailer(); | ||
|
||
putenv('MAILER_DEBUG=1'); | ||
|
||
$configurator->configure($mailer); | ||
|
||
$this->assertEquals(1, $mailer->SMTPDebug); | ||
} | ||
} |