comparison core/modules/user/tests/src/Functional/UserCreateFailMailTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\user\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8 * Tests the create user administration page.
9 *
10 * @group user
11 */
12 class UserCreateFailMailTest extends BrowserTestBase {
13
14 /**
15 * Modules to enable
16 *
17 * @var array
18 */
19 public static $modules = ['system_mail_failure_test'];
20
21 /**
22 * Tests the create user administration page.
23 */
24 public function testUserAdd() {
25 $user = $this->drupalCreateUser(['administer users']);
26 $this->drupalLogin($user);
27
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();
32 $edit = [
33 'name' => $name,
34 'mail' => $this->randomMachineName() . '@example.com',
35 'pass[pass1]' => $pass = $this->randomString(),
36 'pass[pass2]' => $pass,
37 'notify' => TRUE,
38 ];
39 $this->drupalPostForm('admin/people/create', $edit, t('Create new account'));
40
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']]));
43 }
44
45 }