You are here

public function SmsFrameworkUserAccountRegistrationServiceTest::testIncomingPatternActivateEmail in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::testIncomingPatternActivateEmail()
  2. 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::testIncomingPatternActivateEmail()

Ensure account activation email sent.

File

modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php, line 404

Class

SmsFrameworkUserAccountRegistrationServiceTest
Tests account registration.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testIncomingPatternActivateEmail() {
  $this
    ->config('sms_user.settings')
    ->set('account_registration.incoming_pattern.status', TRUE)
    ->set('account_registration.incoming_pattern.incoming_messages.0', "E [email] U [username]")
    ->set('account_registration.incoming_pattern.send_activation_email', TRUE)
    ->save();
  $subject = $this
    ->randomMachineName();
  $this
    ->config('user.mail')
    ->set('register_no_approval_required.subject', $subject)
    ->set('register_no_approval_required.body', 'Foo [user:display-name] Bar')
    ->save();
  $email = 'email@domain.tld';
  $username = $this
    ->randomMachineName();
  $this
    ->sendIncomingMessage('+123123123', 'E ' . $email . ' U ' . $username);
  $emails = $this
    ->getMails();
  $this
    ->assertEquals(1, count($emails), 'One email was sent.');
  $this
    ->assertMailString('to', $email, 1);
  $this
    ->assertMailString('subject', $subject, 1);
  $this
    ->assertMailString('body', 'Foo ' . $username . ' Bar', 1);
}