RealMailTest.php in Swift Mailer 8.2
File
tests/src/Functional/RealMailTest.php
View source
<?php
namespace Drupal\Tests\swiftmailer\Functional;
class RealMailTest extends SwiftMailerTestBase {
public static $modules = [
'user',
'contact',
];
public function testUser() {
$account = $this
->drupalCreateUser();
$this
->config('system.site')
->set('name', 'Rise & shine')
->save();
$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 ');
$this
->assertBodyContains('#Your password for Rise &amp; shine is a&<b<#');
$this
->enablePlain();
$this
->drupalGet('user/password');
$this
->submitForm([
'name' => $account
->getEmail(),
], 'Submit');
$this
->assertBodyContains('#Your password for Rise & shine is a&<b<#');
$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#');
}
public function testContact() {
$edit = [
'label' => 'Help & Support',
'id' => 'contact',
'message' => 'OK',
'recipients' => 'admin@example.com',
'reply' => '',
'selected' => TRUE,
];
$this
->drupalLogin($this
->createUser([
'administer contact forms',
'access site-wide contact form',
]));
$this
->drupalGet('admin/structure/contact/add');
$this
->submitForm($edit, 'Save');
$edit = [
'subject[0][value]' => 'Hello & greetings',
'message[0][value]' => '#I am so happy <grin>#',
];
$this
->drupalGet('contact/contact');
$this
->submitForm($edit, 'Send message');
$this
->assertSubject('[Help & Support] Hello & greetings');
$this
->assertBodyContains('#I am so happy <grin>#');
$this
->enablePlain();
$this
->drupalGet('contact/contact');
$this
->submitForm($edit, 'Send message');
$this
->assertBodyContains('#I am so happy <grin>#');
}
}