Chris@0: drupalCreateUser(['administer users']); Chris@0: $this->drupalLogin($user); Chris@0: Chris@0: // Replace the mail functionality with a fake, malfunctioning service. Chris@0: $this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save(); Chris@0: // Create a user, but fail to send an email. Chris@0: $name = $this->randomMachineName(); Chris@0: $edit = [ Chris@0: 'name' => $name, Chris@0: 'mail' => $this->randomMachineName() . '@example.com', Chris@0: 'pass[pass1]' => $pass = $this->randomString(), Chris@0: 'pass[pass2]' => $pass, Chris@0: 'notify' => TRUE, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/people/create', $edit, t('Create new account')); Chris@0: Chris@0: $this->assertText(t('Unable to send email. Contact the site administrator if the problem persists.')); Chris@0: $this->assertNoText(t('A welcome message with further instructions has been emailed to the new user @name.', ['@name' => $edit['name']])); Chris@0: } Chris@0: Chris@0: }