CiviMailUtils
extends TestCase
in package
Class CiviMailUtils
Table of Contents
Properties
- $_outBound_option : mixed
- Current outbound email option
- $_ut : CiviUnitTestCase
Methods
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Clean up after test.
- assertMailLogEmpty() : mixed
- Check that mail log is empty.
- assertRecipientEmails() : void
- Assert all recipients
- assertRecipients() : mixed
- Assert recipients in the message "to" header.
- assertSubjects() : mixed
- Assert that $expectedSubjects (and no other subjects) were sent.
- checkAllMailLog() : ezcMail|string
- Check contents of mail log.
- checkMailForStrings() : mixed
- checkMailLog() : ezcMail|string
- Check contents of mail log.
- clearMessages() : void
- Remove any sent messages from the log.
- getAllMessages() : mixed
- getMostRecentEmail() : ezcMail|string
- start() : mixed
- Start writing emails to db instead of current option.
- stop() : mixed
- convertToEzc() : ezcMail
Properties
$_outBound_option
Current outbound email option
protected
mixed
$_outBound_option
= \NULL
$_ut
protected
CiviUnitTestCase
$_ut
Methods
__construct()
Constructor.
public
__construct(CiviUnitTestCase &$unit_test[, bool $startImmediately = TRUE ]) : mixed
Parameters
- $unit_test : CiviUnitTestCase
-
The currently running test
- $startImmediately : bool = TRUE
-
Start writing to db now or wait until start() is called.
__destruct()
Clean up after test.
public
__destruct() : mixed
Tags
assertMailLogEmpty()
Check that mail log is empty.
public
assertMailLogEmpty([string $prefix = '' ]) : mixed
Parameters
- $prefix : string = ''
assertRecipientEmails()
Assert all recipients
public
assertRecipientEmails(array<string|int, string> $expectedRecipients) : void
To only check the message "to" header,
Parameters
- $expectedRecipients : array<string|int, string>
-
Semicolon-separated strings, one string per message E.g. ['a@test.com;b@test.com']
Tags
assertRecipients()
Assert recipients in the message "to" header.
public
assertRecipients(array<string|int, mixed> $expectedRecipients) : mixed
To also check cc and bcc,
Parameters
- $expectedRecipients : array<string|int, mixed>
-
Array($msgPos => array($recipPos => $emailAddr)).
Tags
assertSubjects()
Assert that $expectedSubjects (and no other subjects) were sent.
public
assertSubjects(array<string|int, mixed> $expectedSubjects) : mixed
Parameters
- $expectedSubjects : array<string|int, mixed>
-
Array(string $subj).
checkAllMailLog()
Check contents of mail log.
public
checkAllMailLog(array<string|int, mixed> $strings[, array<string|int, mixed> $absentStrings = [] ][, string $prefix = '' ]) : ezcMail|string
Parameters
- $strings : array<string|int, mixed>
-
Strings that should be included.
- $absentStrings : array<string|int, mixed> = []
-
Strings that should not be included.
- $prefix : string = ''
Return values
ezcMail|stringcheckMailForStrings()
public
checkMailForStrings(array<string|int, mixed> $strings, mixed $absentStrings, mixed $prefix, mixed $mail) : mixed
Parameters
- $strings : array<string|int, mixed>
- $absentStrings : mixed
- $prefix : mixed
- $mail : mixed
checkMailLog()
Check contents of mail log.
public
checkMailLog(array<string|int, mixed> $strings[, array<string|int, mixed> $absentStrings = [] ][, string $prefix = '' ]) : ezcMail|string
Parameters
- $strings : array<string|int, mixed>
-
Strings that should be included.
- $absentStrings : array<string|int, mixed> = []
-
Strings that should not be included.
- $prefix : string = ''
Return values
ezcMail|stringclearMessages()
Remove any sent messages from the log.
public
clearMessages([int $limit = 0 ]) : void
Parameters
- $limit : int = 0
-
How many recent messages to remove, defaults to 0 (all).
getAllMessages()
public
getAllMessages([string $type = 'raw' ]) : mixed
Parameters
- $type : string = 'raw'
-
'raw'|'ezc'.
Tags
getMostRecentEmail()
public
getMostRecentEmail([string $type = 'raw' ]) : ezcMail|string
Parameters
- $type : string = 'raw'
Return values
ezcMail|stringstart()
Start writing emails to db instead of current option.
public
start() : mixed
stop()
public
stop() : mixed
convertToEzc()
private
convertToEzc(string $msg) : ezcMail
Parameters
- $msg : string
-
Email header and body.