public function QueueMailFunctionalTest::testCancelMessage in Queue Mail 8
Test that message sending may be canceled.
See also
queue_mail_test_queue_mail_send_alter()
File
- tests/
src/ Functional/ QueueMailFunctionalTest.php, line 176
Class
- QueueMailFunctionalTest
- Tests queue mail functionality.
Namespace
Drupal\Tests\queue_mail\FunctionalCode
public function testCancelMessage() {
$this
->setAllEmailsToBeQueued();
$queue = _queue_mail_get_queue();
$queue_count_init = $queue
->numberOfItems();
// Send test mails.
$params = $this
->getMessageParams();
$this
->sendQueueMailTest('cancel_message', 'cancel@example.com', $params);
$this
->sendQueueMailTest('send_message', 'send@example.com', $params);
// Ensures that both mails in the queue.
$queue_count_after_adding = $queue
->numberOfItems();
$this
->assertEquals(2, $queue_count_after_adding - $queue_count_init, 'Emails are queued.');
$this
->cronRun();
// Checks that queue has been emptied.
$queue_count_after_sending = $queue
->numberOfItems();
$this
->assertEquals($queue_count_init, $queue_count_after_sending, 'Emails have been removed from queue');
// Ensures that just one emails has been sent from two created.
$email_count_after_sending = count($this
->getMails());
$this
->assertEquals(1, $email_count_after_sending, 'One email is sent only.');
$this
->assertMailString('key', 'send_message', 1);
}