class MailTest in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Mail/MailTest.php \Drupal\simplenews\Mail\MailTest
- 8 src/Mail/MailTest.php \Drupal\simplenews\Mail\MailTest
Example mail implementation used for tests.
Hierarchy
- class \Drupal\simplenews\Mail\MailTest implements MailInterface
Expanded class hierarchy of MailTest
1 file declares its use of MailTest
- SimplenewsSourceTest.php in tests/
src/ Functional/ SimplenewsSourceTest.php
File
- src/
Mail/ MailTest.php, line 10
Namespace
Drupal\simplenews\MailView source
class MailTest implements MailInterface {
/**
* The mail format.
*
* @var string
*/
protected $format;
/**
* MailTest constructor.
*
* @param string $format
* The mail format as string, either 'plain' or 'html'.
*/
public function __construct($format) {
$this->format = $format;
}
/**
* {@inheritdoc}
*/
public function getAttachments() {
return [
[
'uri' => 'example://test.png',
'filemime' => 'x-example',
'filename' => 'test.png',
],
];
}
/**
* {@inheritdoc}
*/
public function getBody() {
return $this
->getFormat() == 'plain' ? $this
->getPlainBody() : 'the body';
}
/**
* {@inheritdoc}
*/
public function getFormat() {
return $this->format;
}
/**
* {@inheritdoc}
*/
public function getFromAddress() {
return 'simpletest@example.com';
}
/**
* {@inheritdoc}
*/
public function getFromFormatted() {
return 'Test <simpletest@example.com>';
}
/**
* {@inheritdoc}
*/
public function getHeaders(array $headers) {
$headers['X-Simplenews-Test'] = 'OK';
return $headers;
}
/**
* {@inheritdoc}
*/
public function getKey() {
return 'node';
}
/**
* {@inheritdoc}
*/
public function setKey($key) {
}
/**
* {@inheritdoc}
*/
public function getLanguage() {
return 'en';
}
/**
* {@inheritdoc}
*/
public function getPlainBody() {
return 'the plain body';
}
/**
* {@inheritdoc}
*/
public function getRecipient() {
return 'recipient@example.org';
}
/**
* {@inheritdoc}
*/
public function getSubject() {
return 'the subject';
}
/**
* {@inheritdoc}
*/
public function getTokenContext() {
return [];
}
/**
* {@inheritdoc}
*/
public function getIssue() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getSubscriber() {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MailTest:: |
protected | property | The mail format. | |
MailTest:: |
public | function |
Returns an array of attachments for this newsletter mail. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail body. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail format. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the plain mail address. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the formatted from mail address. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail headers. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the newsletter issue entity. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail key to be used for mails. Overrides MailInterface:: |
|
MailTest:: |
public | function |
The language that should be used for this newsletter mail. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the plaintext body. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the recipient of this newsletter mail. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail subject. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the subscriber object. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the token context to be used with token replacements. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Set the mail key. Overrides MailInterface:: |
|
MailTest:: |
public | function | MailTest constructor. |