You are here

class MailTest in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Mail/MailTest.php \Drupal\simplenews\Mail\MailTest
  2. 3.x src/Mail/MailTest.php \Drupal\simplenews\Mail\MailTest

Example mail implementation used for tests.

Hierarchy

Expanded class hierarchy of MailTest

1 file declares its use of MailTest
SimplenewsSourceTest.php in src/Tests/SimplenewsSourceTest.php
Simplenews source test functions.

File

src/Mail/MailTest.php, line 10

Namespace

Drupal\simplenews\Mail
View source
class MailTest implements MailInterface {
  protected $format;
  public function __construct($format) {
    $this->format = $format;
  }
  public function getAttachments() {
    return array(
      array(
        'uri' => 'example://test.png',
        'filemime' => 'x-example',
        'filename' => 'test.png',
      ),
    );
  }
  public function getBody() {
    return $this
      ->getFormat() == 'plain' ? $this
      ->getPlainBody() : 'the body';
  }
  public function getFormat() {
    return $this->format;
  }
  public function getFromAddress() {
    return 'simpletest@example.com';
  }
  public function getFromFormatted() {
    return 'Test <simpletest@example.com>';
  }
  public function getHeaders(array $headers) {
    $headers['X-Simplenews-Test'] = 'OK';
    return $headers;
  }
  public function getKey() {
    return 'node';
  }
  public function setKey($key) {
  }
  public function getLanguage() {
    return 'en';
  }
  public function getPlainBody() {
    return 'the plain body';
  }
  public function getRecipient() {
    return 'recipient@example.org';
  }
  public function getSubject() {
    return 'the subject';
  }
  public function getTokenContext() {
    return array();
  }

  /**
   * @inheritDoc
   */
  function getEntity() {
    return NULL;
  }

  /**
   * @inheritDoc
   */
  function getSubscriber() {
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MailTest::$format protected property
MailTest::getAttachments public function Returns an array of attachments for this newsletter mail. Overrides MailInterface::getAttachments
MailTest::getBody public function Returns the mail body. Overrides MailInterface::getBody
MailTest::getEntity function @inheritDoc Overrides MailInterface::getEntity
MailTest::getFormat public function Returns the mail format. Overrides MailInterface::getFormat
MailTest::getFromAddress public function Returns the plain mail address. Overrides MailInterface::getFromAddress
MailTest::getFromFormatted public function Returns the formatted from mail address. Overrides MailInterface::getFromFormatted
MailTest::getHeaders public function Returns the mail headers. Overrides MailInterface::getHeaders
MailTest::getKey public function Returns the mail key to be used for mails. Overrides MailInterface::getKey
MailTest::getLanguage public function The language that should be used for this newsletter mail. Overrides MailInterface::getLanguage
MailTest::getPlainBody public function Returns the plaintext body. Overrides MailInterface::getPlainBody
MailTest::getRecipient public function Returns the recipient of this newsletter mail. Overrides MailInterface::getRecipient
MailTest::getSubject public function Returns the mail subject. Overrides MailInterface::getSubject
MailTest::getSubscriber function @inheritDoc Overrides MailInterface::getSubscriber
MailTest::getTokenContext public function Returns the token context to be used with token replacements. Overrides MailInterface::getTokenContext
MailTest::setKey public function Set the mail key. Overrides MailInterface::setKey
MailTest::__construct public function