Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Burgess authored and monishdeb committed Jan 10, 2017
1 parent 16d7df9 commit 86c5097
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public function setUp() {
'contact_type' => 'Individual',
'email' => 'test-member@example.com',
'gender_id' => 'Female',
'first_name' => 'Churmondleia',
'last_name' => 'Ōtākou',
);
$this->fixtures['contact_birthdate'] = array(
'is_deceased' => 0,
Expand Down Expand Up @@ -603,7 +605,6 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();

$this->mut->clearMessages();
$this->mut->stop();
unset($this->mut);
Expand All @@ -621,30 +622,37 @@ public function tearDown() {
public function mailerExamples() {
$cases = array();

$manyTokensTmpl = implode(';;', array(
// Some tokens - short as subject has 128char limit in DB.
$someTokensTmpl = implode(';;', array(
'{contact.display_name}', // basic contact token
'{contact.gender}', // funny legacy contact token
'{contact.gender_id}', // funny legacy contact token
'{domain.name}', // domain token
'{activity.activity_type}', // action-scheduler token
));
// Further tokens can be tested in the body text/html.
$manyTokensTmpl = implode(';;', array(
$someTokensTmpl,
'{contact.email_greeting}',
));
// Note: The behavior of domain-tokens on a scheduled reminder is undefined. All we
// can really do is check that it has something.
$manyTokensExpected = 'test-member@example.com;;Female;;Female;;[a-zA-Z0-9 ]+;;Phone Call';
$someTokensExpected = 'Churmondleia Ōtākou;;Female;;Female;;[a-zA-Z0-9 ]+;;Phone Call';
$manyTokensExpected = "$someTokensExpected;;Dear Churmondleia";

// In this example, we use a lot of tokens cutting across multiple components..
// In this example, we use a lot of tokens cutting across multiple components.
$cases[0] = array(
// Schedule definition.
array(
'subject' => "subj $manyTokensTmpl",
'subject' => "subj $someTokensTmpl",
'body_html' => "html $manyTokensTmpl",
'body_text' => "text $manyTokensTmpl",
),
// Assertions (regex).
array(
'from_name' => "/^FIXME\$/",
'from_email' => "/^info@EXAMPLE.ORG\$/",
'subject' => "/^subj $manyTokensExpected\$/",
'subject' => "/^subj $someTokensExpected\$/",
'body_html' => "/^html $manyTokensExpected\$/",
'body_text' => "/^text $manyTokensExpected\$/",
),
Expand Down Expand Up @@ -755,7 +763,6 @@ public function testMailer($schedule, $patterns) {
}
}
$this->mut->clearMessages();

}

public function testActivityDateTimeMatchNonRepeatableSchedule() {
Expand Down

0 comments on commit 86c5097

Please sign in to comment.