Skip to content

Commit

Permalink
More email tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Feb 20, 2017
1 parent 1584a0b commit bfd354f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/phpunit/tests/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Required\Digest\Tests;

use MockPHPMailer;
use Required\Digest\Queue;
use \WP_UnitTestCase;
use \MockAction;
Expand Down Expand Up @@ -35,4 +36,27 @@ public function test_send_email_empty_queue() {

$this->assertSame( 0, $action->get_call_count() );
}

public function test_send_email_non_empty_queue() {
Queue::add( '[email protected]', 'foo', 'bar' );

digest()->send_email( 'Foo' );

/** @var MockPHPMailer $mailer */
$mailer = tests_retrieve_phpmailer_instance();

$this->assertSame( 'Foo', $mailer->Subject );
}

public function test_send_email_non_empty_queue_registered_events() {
Queue::add( '[email protected]', 'core_update_success', '100.1.0' );

digest()->send_email( 'Foo' );

/** @var MockPHPMailer $mailer */
$mailer = tests_retrieve_phpmailer_instance();

$this->assertSame( 'Foo', $mailer->get_sent()->subject );
$this->assertContains( 'Hi there', $mailer->get_sent()->body );
}
}

0 comments on commit bfd354f

Please sign in to comment.