You are here

public function SendAccountEmailTest::testActionExecution in Rules 8.3

Tests the action execution.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/SendAccountEmailTest.php, line 60

Class

SendAccountEmailTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\SendAccountEmail @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecution() {
  $account = $this
    ->prophesizeEntity(UserInterface::class);
  $account->mail = 'klausi@example.com';
  $mail_type = 'test_mail_type';
  $this->action
    ->setContextValue('user', $account
    ->reveal())
    ->setContextValue('email_type', $mail_type);
  $this->action
    ->execute();

  // To get the notifications that were sent, we call _user_mail_notify()
  // with no parameters.
  $notifications = _user_mail_notify();
  $this
    ->assertSame([
    $mail_type => 1,
  ], $notifications);
}