You are here

public function MandrillTemplateTestCase::testSendTemplatedMessage in Mandrill 8

Test sending a templated message to multiple recipients.

File

modules/mandrill_template/tests/src/Functional/MandrillTemplateTestCase.php, line 58
Test class and methods for the Mandrill Template module.

Class

MandrillTemplateTestCase
Test Mandrill Template functionality.

Namespace

Drupal\mandrill_template\Tests

Code

public function testSendTemplatedMessage() {
  $to = 'Recipient One <recipient.one@example.com>,' . 'Recipient Two <recipient.two@example.com>,' . 'Recipient Three <recipient.three@example.com>';
  $message = $this
    ->getMessageTestData();
  $message['to'] = $to;
  $template_id = 'Test Template';
  $template_content = array(
    'name' => 'Recipient',
  );

  /* @var $mandrillAPI \Drupal\mandrill\MandrillTestAPI */
  $mandrillAPI = \Drupal::service('mandrill.test.api');
  $response = $mandrillAPI
    ->sendTemplate($message, $template_id, $template_content);
  $this
    ->assertNotNull($response, 'Tested response from sending templated message.');
  if (isset($response['status'])) {
    $this
      ->assertNotEqual($response['status'], 'error', 'Tested response status: ' . $response['status'] . ', ' . $response['message']);
  }
}