diff --git a/core/lib/Drupal/Core/Mail/MalPhpMail.php b/core/lib/Drupal/Core/Mail/MalPhpMail.php deleted file mode 100644 index f55cebc..0000000 --- a/core/lib/Drupal/Core/Mail/MalPhpMail.php +++ /dev/null @@ -1,23 +0,0 @@ - 'User create with failed mail function', @@ -22,32 +25,25 @@ public static function getInfo() { ); } - /** - * Create a user through the administration interface and ensure that it - * displays proper message when mail does not work. - */ + // Test the create user administration page. protected function testUserAdd() { $user = $this->drupalCreateUser(array('administer users')); $this->drupalLogin($user); - // We stop mail function - $mail_system_variable = config('system.mail')->get('interface.default'); - config('system.mail')->set('interface.default', 'Drupal\Core\Mail\MalPhpMail')->save(); - // We create a user, notify the created user and fail to send email. + // Replace the mail functionality with a fake, malfunctioning service. + config('system.mail')->set('interface.default', 'Drupal\user_mail_failure_test\TestPhpMailFailure')->save(); + // Create a user, but fail to send an email. $name = $this->randomName(); $edit = array( 'name' => $name, 'mail' => $this->randomName() . '@example.com', 'pass[pass1]' => $pass = $this->randomString(), 'pass[pass2]' => $pass, - 'notify' => true, + 'notify' => TRUE, ); $this->drupalPost('admin/people/create', $edit, t('Create new account')); - $this->assertText(t('Unable to send e-mail. Contact the site administrator if the problem persists.'),'Error message for disfunctional mail.'); - $this->assertNoText(t('A welcome message with further instructions has been e-mailed to the new user @name.', array('@name' => $edit['name'])), 'Do not show welcome message'); - - // Set the old variable back. - config('system.mail')->set('interface.default', $mail_system_variable)->save(); + $this->assertText(t('Unable to send e-mail. Contact the site administrator if the problem persists.')); + $this->assertNoText(t('A welcome message with further instructions has been e-mailed to the new user @name.', array('@name' => $edit['name']))); } } diff --git a/core/modules/user/tests/modules/user_mail_failure_test/lib/Drupal/user_mail_failure_test/TestPhpMailFailure.php b/core/modules/user/tests/modules/user_mail_failure_test/lib/Drupal/user_mail_failure_test/TestPhpMailFailure.php new file mode 100644 index 0000000..5ed8797 --- /dev/null +++ b/core/modules/user/tests/modules/user_mail_failure_test/lib/Drupal/user_mail_failure_test/TestPhpMailFailure.php @@ -0,0 +1,26 @@ +