class UserCreateFailMailTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Functional/UserCreateFailMailTest.php \Drupal\Tests\user\Functional\UserCreateFailMailTest
- 10 core/modules/user/tests/src/Functional/UserCreateFailMailTest.php \Drupal\Tests\user\Functional\UserCreateFailMailTest
- 8.9.x core/modules/user/tests/src/Functional/UserCreateFailMailTest.php \Drupal\Tests\user\Functional\UserCreateFailMailTest
Tests the create user administration page.
@group user
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\user\Functional\UserCreateFailMailTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of UserCreateFailMailTest
File
-
core/
modules/ user/ tests/ src/ Functional/ UserCreateFailMailTest.php, line 12
Namespace
Drupal\Tests\user\FunctionalView source
class UserCreateFailMailTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'system_mail_failure_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the create user administration page.
*/
public function testUserAdd() {
$user = $this->drupalCreateUser([
'administer users',
]);
$this->drupalLogin($user);
// Replace the mail functionality with a fake, malfunctioning service.
$this->config('system.mail')
->set('interface.default', 'test_php_mail_failure')
->save();
// Create a user, but fail to send an email.
$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'] . '.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.