public function RealMailTest::testUser in Swift Mailer 8.2
Tests user account messages.
File
- tests/src/ Functional/ RealMailTest.php, line 20 
Class
- RealMailTest
- Tests with real mails generated by Drupal Core.
Namespace
Drupal\Tests\swiftmailer\FunctionalCode
public function testUser() {
  $account = $this
    ->drupalCreateUser();
  $this
    ->config('system.site')
    ->set('name', 'Rise & shine')
    ->save();
  // Password reset.
  $this
    ->config('user.mail')
    ->set('password_reset.subject', 'You forgot <again>')
    ->set('password_reset.body', '#Your password for [site:name] is a&<b<#')
    ->save();
  $this
    ->drupalGet('user/password');
  $this
    ->submitForm([
    'name' => $account
      ->getEmail(),
  ], 'Submit');
  $this
    ->assertSubject('You forgot ');
  // @todo Should be $this->assertSubject('You forgot <again>');
  $this
    ->assertBodyContains('#Your password for Rise &amp; shine is a&<b<#');
  // @todo Should be $this->assertBodyContains('#Your password for Rise & shine is a&<b<#');
  // Plain text.
  $this
    ->enablePlain();
  $this
    ->drupalGet('user/password');
  $this
    ->submitForm([
    'name' => $account
      ->getEmail(),
  ], 'Submit');
  $this
    ->assertBodyContains('#Your password for Rise & shine is a&<b<#');
  // @todo Should be $this->assertBodyContains('#Your password for Rise & shine is a&<b<#');
  // Account notification message.
  $this
    ->config('user.settings')
    ->set('notify.status_activated', TRUE)
    ->save();
  $this
    ->config('user.mail')
    ->set('status_activated.body', '#ACTIVATED#')
    ->save();
  _user_mail_notify('status_activated', $account);
  $this
    ->assertBodyContains('#ACTIVATED#');
}