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