From ce9f2601f8268b5f254be37eac8cfdb85b371d51 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 1 Mar 2021 21:34:09 +1100 Subject: [PATCH] [NFC] Add in unit test to prove that domain tokens are able to be incldued in peition emails --- .../phpunit/CRM/Campaign/BAO/PetitionTest.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/phpunit/CRM/Campaign/BAO/PetitionTest.php diff --git a/tests/phpunit/CRM/Campaign/BAO/PetitionTest.php b/tests/phpunit/CRM/Campaign/BAO/PetitionTest.php new file mode 100644 index 000000000000..33e8ae524231 --- /dev/null +++ b/tests/phpunit/CRM/Campaign/BAO/PetitionTest.php @@ -0,0 +1,62 @@ +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(); + } + +}