You are here

class Test in Mail System 8.4

Provides a test plugin to send emails.

Hierarchy

Expanded class hierarchy of Test

File

tests/src/Unit/AdapterTest.php, line 88

Namespace

Drupal\Tests\mailsystem\Unit
View source
class Test implements MailInterface {
  const TEST_SUBJECT = 'Subject';
  const TEST_BODY = 'Vivamus varius commodo leo at eleifend. Nunc vestibulum dolor eget turpis pulvinar volutpat.';
  const TEST_HEADER_NAME = 'X-System';
  const TEST_HEADER_VALUE = 'D8 PHP Unit test';
  const SEND_SUCCESS_SUBJECT = 'Failed';

  /**
   * {@inheritdoc}
   */
  public function format(array $message) {
    return [
      'subject' => self::TEST_SUBJECT,
      'body' => self::TEST_BODY,
      'headers' => [
        self::TEST_HEADER_NAME => self::TEST_HEADER_VALUE,
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function mail(array $message) {
    return $message['subject'] == self::SEND_SUCCESS_SUBJECT;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Test::format public function Formats a message prior to sending. Overrides MailInterface::format
Test::mail public function Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail(). Overrides MailInterface::mail
Test::SEND_SUCCESS_SUBJECT constant
Test::TEST_BODY constant
Test::TEST_HEADER_NAME constant
Test::TEST_HEADER_VALUE constant
Test::TEST_SUBJECT constant