-
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.
- Loading branch information
1 parent
9eaf7c6
commit 5602f2e
Showing
1 changed file
with
42 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
use Studiometa\WPToolkit\Managers\EmailManager; | ||
|
||
/** | ||
* EmailManagerTest test case. | ||
*/ | ||
class EmailManagerTest extends WP_UnitTestCase { | ||
|
||
/** | ||
* Test configure PHPMailer with SMTP server. | ||
* | ||
* @return void | ||
*/ | ||
public function test_smtp_configuration() { | ||
$_ENV['MAIL_MAILER'] = 'smtp'; | ||
$_ENV['MAIL_HOST'] = '127.0.0.1'; | ||
$_ENV['MAIL_PORT'] = '1025'; | ||
$_ENV['MAIL_USERNAME'] = 'test'; | ||
$_ENV['MAIL_PASSWORD'] = 'test'; | ||
$_ENV['MAIL_AUTH'] = 'true'; | ||
$_ENV['MAIL_ENCRYPTION'] = 'tls'; | ||
|
||
$manager = new EmailManager(); | ||
$manager->run(); | ||
|
||
// Trigger phpmailer configuration action. | ||
global $phpmailer; | ||
assert( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ); | ||
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); | ||
|
||
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
$this->assertSame( $phpmailer->Mailer, 'smtp' ); | ||
$this->assertSame( $phpmailer->Host, '127.0.0.1' ); | ||
$this->assertSame( $phpmailer->Port, 1025 ); | ||
$this->assertSame( $phpmailer->Username, 'test' ); | ||
$this->assertSame( $phpmailer->Password, 'test' ); | ||
$this->assertSame( $phpmailer->SMTPAuth, true ); | ||
$this->assertSame( $phpmailer->SMTPSecure, 'tls' ); | ||
// phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase | ||
} | ||
} |