-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19702 from seamuslee001/domain_petition_emails
[NFC] Add in unit test to prove that domain tokens are able to be inc…
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* | ||
* @package CRM | ||
* @copyright CiviCRM LLC https://civicrm.org/licensing | ||
*/ | ||
class CRM_Campaign_BAO_PetitionTest extends CiviUnitTestCase { | ||
|
||
/** | ||
* Test Petition Email Sending using Domain tokens | ||
*/ | ||
public function testPetitionEmailWithDomainTokens() { | ||
$mut = new CiviMailUtils($this, TRUE); | ||
$domain = $this->callAPISuccess('Domain', 'getsingle', ['id' => CRM_Core_Config::domainID()]); | ||
$this->callAPISuccess('Address', 'create', [ | ||
'contact_id' => $domain['contact_id'], | ||
'location_type_id' => 'Billing', | ||
'street_address' => '1600 Pennsylvania Avenue', | ||
'city' => 'Washington', | ||
'state_province_id' => 'District of Columbia', | ||
'country_id' => 'US', | ||
'postal_code' => '20500', | ||
]); | ||
$template_contact = CRM_Core_DAO::singleValueQuery("SELECT msg_html FROM civicrm_msg_template WHERE workflow_name = 'petition_sign' AND is_default = 1"); | ||
$template_contact .= ' | ||
{domain.address}'; | ||
CRM_Core_DAO::executeQuery("UPDATE civicrm_msg_template SET msg_html = '{$template_contact}' WHERE workflow_name = 'petition_sign' AND is_default = 1"); | ||
$contact = $this->individualCreate(); | ||
$email = $this->callAPISuccess('email', 'create', [ | ||
'contact_id' => $contact, | ||
'email' => 'testpetitioncontact@civicrm.org', | ||
]); | ||
$survey = $this->callAPISuccess('Survey', 'create', [ | ||
'title' => 'Test Petition', | ||
'activity_type_id' => 'Petition', | ||
'bypass_confirm' => 1, | ||
]); | ||
$params = [ | ||
'sid' => $survey['id'], | ||
'contactId' => $contact, | ||
'email-Primary' => 'testpetitioncontact@civicrm.org', | ||
]; | ||
CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK); | ||
$mut->checkMailLog([ | ||
'1600 Pennsylvania Avenue', | ||
'Washington', | ||
]); | ||
$mut->stop(); | ||
} | ||
|
||
} |