class TestMailManager

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\TestMailManager
  2. 10 core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\TestMailManager
  3. 8.9.x core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php \Drupal\Tests\Core\Mail\TestMailManager

Provides a testing version of MailManager with an empty constructor.

Hierarchy

Expanded class hierarchy of TestMailManager

File

core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php, line 173

Namespace

Drupal\Tests\Core\Mail
View source
class TestMailManager extends MailManager {
  
  /**
   * Sets the discovery for the manager.
   *
   * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $discovery
   *   The discovery object.
   */
  public function setDiscovery(DiscoveryInterface $discovery) {
    $this->discovery = $discovery;
  }
  
  /**
   * {@inheritdoc}
   */
  public function doMail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
    // Build a simplified message array and return it.
    $message = [
      'id' => $module . '_' . $key,
      'module' => $module,
      'key' => $key,
      'to' => $to,
      'from' => 'from@example.org',
      'reply-to' => $reply,
      'langcode' => $langcode,
      'params' => $params,
      'send' => TRUE,
      'subject' => '',
      'body' => [],
    ];
    return $message;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.