UserCreateFailMailTest.php in Drupal 10
File
core/modules/user/tests/src/Functional/UserCreateFailMailTest.php
View source
<?php
namespace Drupal\Tests\user\Functional;
use Drupal\Tests\BrowserTestBase;
class UserCreateFailMailTest extends BrowserTestBase {
protected static $modules = [
'system_mail_failure_test',
];
protected $defaultTheme = 'stark';
public function testUserAdd() {
$user = $this
->drupalCreateUser([
'administer users',
]);
$this
->drupalLogin($user);
$this
->config('system.mail')
->set('interface.default', 'test_php_mail_failure')
->save();
$name = $this
->randomMachineName();
$edit = [
'name' => $name,
'mail' => $this
->randomMachineName() . '@example.com',
'pass[pass1]' => $pass = $this
->randomString(),
'pass[pass2]' => $pass,
'notify' => TRUE,
];
$this
->drupalGet('admin/people/create');
$this
->submitForm($edit, 'Create new account');
$this
->assertSession()
->pageTextContains('Unable to send email. Contact the site administrator if the problem persists.');
$this
->assertSession()
->pageTextNotContains('A welcome message with further instructions has been emailed to the new user ' . $edit['name'] . '.');
}
}