Issue #1928440 by ar-jan: Rename incorrectly named MailInterface implementations.
parent
2026f92d45
commit
c84786171e
|
@ -62,7 +62,7 @@ class MailFactory {
|
||||||
* @code
|
* @code
|
||||||
* array(
|
* array(
|
||||||
* 'default' => 'Drupal\Core\Mail\PhpMail',
|
* 'default' => 'Drupal\Core\Mail\PhpMail',
|
||||||
* 'user' => 'DevelMailLog',
|
* 'user' => 'Drupal\devel\DevelMailLog',
|
||||||
* );
|
* );
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
|
@ -72,8 +72,8 @@ class MailFactory {
|
||||||
* @code
|
* @code
|
||||||
* array(
|
* array(
|
||||||
* 'default' => 'Drupal\Core\Mail\PhpMail',
|
* 'default' => 'Drupal\Core\Mail\PhpMail',
|
||||||
* 'user' => 'DevelMailLog',
|
* 'user' => 'Drupal\devel\DevelMailLog',
|
||||||
* 'contact_page_autoreply' => 'DrupalDevNullMailSend',
|
* 'contact_page_autoreply' => 'Drupal\example\NullMail',
|
||||||
* );
|
* );
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains \Drupal\Core\Mail\TestMailCollector.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\Core\Mail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a mail sending implementation that captures sent messages to the
|
||||||
|
* state system.
|
||||||
|
*
|
||||||
|
* This class is for running tests or for development.
|
||||||
|
*/
|
||||||
|
class TestMailCollector extends PhpMail implements MailInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides \Drupal\Core\Mail\PhpMail::mail().
|
||||||
|
*
|
||||||
|
* Accepts an e-mail message and stores it with the state system.
|
||||||
|
*/
|
||||||
|
public function mail(array $message) {
|
||||||
|
$captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: array();
|
||||||
|
$captured_emails[] = $message;
|
||||||
|
\Drupal::state()->set('system.test_mail_collector', $captured_emails);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Definition of Drupal\Core\Mail\VariableLog.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Drupal\Core\Mail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a mail sending implementation that captures sent messages to a
|
|
||||||
* variable.
|
|
||||||
*
|
|
||||||
* This class is for running tests or for development.
|
|
||||||
*/
|
|
||||||
class VariableLog extends PhpMail implements MailInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides Drupal\Core\Mail\PhpMail::mail().
|
|
||||||
*
|
|
||||||
* Accepts an e-mail message and store it in a variable.
|
|
||||||
*/
|
|
||||||
public function mail(array $message) {
|
|
||||||
$captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
|
|
||||||
$captured_emails[] = $message;
|
|
||||||
\Drupal::state()->set('system.test_email_collector', $captured_emails);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1075,7 +1075,7 @@ abstract class TestBase {
|
||||||
drupal_static_reset();
|
drupal_static_reset();
|
||||||
|
|
||||||
if ($this->container->has('state') && $state = $this->container->get('state')) {
|
if ($this->container->has('state') && $state = $this->container->get('state')) {
|
||||||
$captured_emails = $state->get('system.test_email_collector') ?: array();
|
$captured_emails = $state->get('system.test_mail_collector') ?: array();
|
||||||
$emailCount = count($captured_emails);
|
$emailCount = count($captured_emails);
|
||||||
if ($emailCount) {
|
if ($emailCount) {
|
||||||
$message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
|
$message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
|
||||||
|
|
|
@ -844,7 +844,7 @@ abstract class WebTestBase extends TestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the test mail class instead of the default mail handler class.
|
// Use the test mail class instead of the default mail handler class.
|
||||||
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\VariableLog')->save();
|
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\TestMailCollector')->save();
|
||||||
|
|
||||||
drupal_set_time_limit($this->timeLimit);
|
drupal_set_time_limit($this->timeLimit);
|
||||||
// Temporary fix so that when running from run-tests.sh we don't get an
|
// Temporary fix so that when running from run-tests.sh we don't get an
|
||||||
|
@ -2452,7 +2452,7 @@ abstract class WebTestBase extends TestBase {
|
||||||
* An array containing e-mail messages captured during the current test.
|
* An array containing e-mail messages captured during the current test.
|
||||||
*/
|
*/
|
||||||
protected function drupalGetMails($filter = array()) {
|
protected function drupalGetMails($filter = array()) {
|
||||||
$captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
|
$captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: array();
|
||||||
$filtered_emails = array();
|
$filtered_emails = array();
|
||||||
|
|
||||||
foreach ($captured_emails as $message) {
|
foreach ($captured_emails as $message) {
|
||||||
|
@ -3449,7 +3449,7 @@ abstract class WebTestBase extends TestBase {
|
||||||
* TRUE on pass, FALSE on fail.
|
* TRUE on pass, FALSE on fail.
|
||||||
*/
|
*/
|
||||||
protected function assertMail($name, $value = '', $message = '', $group = 'E-mail') {
|
protected function assertMail($name, $value = '', $message = '', $group = 'E-mail') {
|
||||||
$captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
|
$captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: array();
|
||||||
$email = end($captured_emails);
|
$email = end($captured_emails);
|
||||||
return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group);
|
return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ class InstallerTranslationTest extends InstallerTest {
|
||||||
), $submit_value);
|
), $submit_value);
|
||||||
|
|
||||||
// Use the test mail class instead of the default mail handler class.
|
// Use the test mail class instead of the default mail handler class.
|
||||||
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\VariableLog')->save();
|
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\TestMailCollector')->save();
|
||||||
|
|
||||||
drupal_set_time_limit($this->timeLimit);
|
drupal_set_time_limit($this->timeLimit);
|
||||||
// When running from run-tests.sh we don't get an empty current path which
|
// When running from run-tests.sh we don't get an empty current path which
|
||||||
|
|
|
@ -96,7 +96,7 @@ class InstallerTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the test mail class instead of the default mail handler class.
|
// Use the test mail class instead of the default mail handler class.
|
||||||
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\VariableLog')->save();
|
\Drupal::config('system.mail')->set('interface.default', 'Drupal\Core\Mail\TestMailCollector')->save();
|
||||||
|
|
||||||
drupal_set_time_limit($this->timeLimit);
|
drupal_set_time_limit($this->timeLimit);
|
||||||
// When running from run-tests.sh we don't get an empty current path which
|
// When running from run-tests.sh we don't get an empty current path which
|
||||||
|
|
Loading…
Reference in New Issue