class MailTest in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Mail/MailTest.php \Drupal\simplenews\Mail\MailTest
- 3.x 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 src/
Tests/ SimplenewsSourceTest.php - Simplenews source test functions.
File
- src/
Mail/ MailTest.php, line 10
Namespace
Drupal\simplenews\MailView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MailTest:: |
protected | property | ||
MailTest:: |
public | function |
Returns an array of attachments for this newsletter mail. Overrides MailInterface:: |
|
MailTest:: |
public | function |
Returns the mail body. Overrides MailInterface:: |
|
MailTest:: |
function |
@inheritDoc 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 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:: |
function |
@inheritDoc 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 |