Commit a2c97c9b authored by webchick's avatar webchick
Browse files

Issue #1824768 by vijaycs85: Convert drupal_test_email_collector() variable to CMI system.

parent d029eeb5
......@@ -21,9 +21,9 @@ class VariableLog extends PhpMail implements MailInterface {
* Accepts an e-mail message and store it in a variable.
*/
public function mail(array $message) {
$captured_emails = variable_get('drupal_test_email_collector', array());
$captured_emails = state()->get('system.test_email_collector') ?: array();
$captured_emails[] = $message;
variable_set('drupal_test_email_collector', $captured_emails);
state()->set('system.test_email_collector', $captured_emails);
return TRUE;
}
......
......@@ -963,8 +963,8 @@ protected function tearDown() {
// In case a fatal error occurred that was not in the test process read the
// log to pick up any fatal errors.
simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
$emailCount = count(variable_get('drupal_test_email_collector', array()));
$captured_emails = state()->get('system.test_email_collector') ?: array();
$emailCount = count($captured_emails);
if ($emailCount) {
$message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
$this->pass($message, t('E-mail'));
......
......@@ -2000,7 +2000,7 @@ protected function drupalGetSettings() {
* An array containing e-mail messages captured during the current test.
*/
protected function drupalGetMails($filter = array()) {
$captured_emails = variable_get('drupal_test_email_collector', array());
$captured_emails = state()->get('system.test_email_collector') ?: array();
$filtered_emails = array();
foreach ($captured_emails as $message) {
......@@ -2923,7 +2923,7 @@ protected function assertNoResponse($code, $message = '') {
* TRUE on pass, FALSE on fail.
*/
protected function assertMail($name, $value = '', $message = '') {
$captured_emails = variable_get('drupal_test_email_collector', array());
$captured_emails = state()->get('system.test_email_collector') ?: array();
$email = end($captured_emails);
return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, t('E-mail'));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment