function SystemSendEmailTest::testSendMailToTwoRecipients
Tests sending a mail to two recipients.
@covers ::execute
File
-
tests/
src/ Unit/ Integration/ RulesAction/ SystemSendEmailTest.php, line 99
Class
- SystemSendEmailTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesAction\SystemSendEmail @group RulesAction
Namespace
Drupal\Tests\rules\Unit\Integration\RulesActionCode
public function testSendMailToTwoRecipients() {
$to = [
'mail@example.com',
'mail2@example.com',
];
// Use a language other than the site default.
$language = $this->prophesize(LanguageInterface::class);
$language->getId()
->willReturn('da');
$this->action
->setContextValue('to', $to)
->setContextValue('subject', 'subject')
->setContextValue('message', 'hello')
->setContextValue('language', $language->reveal());
$params = [
'subject' => 'subject',
'message' => 'hello',
];
$this->mailManager
->mail('rules', 'rules_action_mail_' . $this->action
->getPluginId(), implode(', ', $to), $language->reveal()
->getId(), $params, NULL)
->willReturn([
'result' => TRUE,
])
->shouldBeCalledTimes(1);
$this->action
->execute();
$this->logger
->notice('Successfully sent email to %recipient', [
'%recipient' => implode(', ', $to),
])
->shouldHaveBeenCalled();
}