function SystemSendEmailTest::testSendMailToOneRecipient
Tests sending a mail to one recipient.
@covers ::execute
File
-
tests/
src/ Unit/ Integration/ RulesAction/ SystemSendEmailTest.php, line 66
Class
- SystemSendEmailTest
- @coversDefaultClass \Drupal\rules\Plugin\RulesAction\SystemSendEmail @group RulesAction
Namespace
Drupal\Tests\rules\Unit\Integration\RulesActionCode
public function testSendMailToOneRecipient() {
$to = [
'mail@example.com',
];
$this->action
->setContextValue('to', $to)
->setContextValue('subject', 'subject')
->setContextValue('message', 'hello');
$params = [
'subject' => 'subject',
'message' => 'hello',
];
$this->mailManager
->mail('rules', 'rules_action_mail_' . $this->action
->getPluginId(), implode(', ', $to), LanguageInterface::LANGCODE_SITE_DEFAULT, $params, NULL)
->willReturn([
'result' => TRUE,
])
->shouldBeCalledTimes(1);
$this->action
->execute();
$this->logger
->notice('Successfully sent email to %recipient', [
'%recipient' => implode(', ', $to),
])
->shouldHaveBeenCalled();
}