3 namespace Drupal\Tests\user\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the create user administration page.
12 class UserCreateFailMailTest extends BrowserTestBase {
19 public static $modules = ['system_mail_failure_test'];
22 * Tests the create user administration page.
24 public function testUserAdd() {
25 $user = $this->drupalCreateUser(['administer users']);
26 $this->drupalLogin($user);
28 // Replace the mail functionality with a fake, malfunctioning service.
29 $this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
30 // Create a user, but fail to send an email.
31 $name = $this->randomMachineName();
34 'mail' => $this->randomMachineName() . '@example.com',
35 'pass[pass1]' => $pass = $this->randomString(),
36 'pass[pass2]' => $pass,
39 $this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
41 $this->assertText(t('Unable to send email. Contact the site administrator if the problem persists.'));
42 $this->assertNoText(t('A welcome message with further instructions has been emailed to the new user @name.', ['@name' => $edit['name']]));