-
-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2747 Reconcile remaining fields between scheduled reminders and legacy tokens #21046
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,14 +568,7 @@ public static function contributionTokens(): array { | |
foreach ($processor->getAllTokens() as $token => $title) { | ||
$tokens['{contribution.' . $token . '}'] = $title; | ||
} | ||
return array_merge($tokens, [ | ||
'{contribution.cancel_reason}' => ts('Contribution Cancel Reason'), | ||
'{contribution.amount_level}' => ts('Amount Level'), | ||
'{contribution.check_number}' => ts('Check Number'), | ||
'{contribution.campaign}' => ts('Contribution Campaign'), | ||
// @todo - we shouldn't need to include custom fields here - | ||
// remove, with test. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removed lines are from the function that determins the tokens that show up here. Per the comments I thought the custom field line was also redundant & UI testing should it to be true - I wound up UI testing rather than unit |
||
], CRM_Utils_Token::getCustomFieldTokens('Contribution', TRUE)); | ||
return $tokens; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
use Civi\Api4\Contribution; | ||
|
||
/** | ||
* Class CRM_Contribute_ActionMapping_ByTypeTest | ||
* @group ActionSchedule | ||
|
@@ -151,6 +153,8 @@ public function createTestCases() { | |
* Create a contribution record for Alice with type "Member Dues". | ||
*/ | ||
public function addAliceDues(): void { | ||
$this->enableCiviCampaign(); | ||
$campaignID = $this->campaignCreate(); | ||
$this->ids['Contribution']['alice'] = $this->callAPISuccess('Contribution', 'create', [ | ||
'contact_id' => $this->contacts['alice']['id'], | ||
'receive_date' => date('Ymd', strtotime($this->targetDate)), | ||
|
@@ -164,6 +168,7 @@ public function addAliceDues(): void { | |
// Having a cancel date is a bit artificial here but we can test it.... | ||
'cancel_date' => '2021-08-09', | ||
'contribution_status_id' => 1, | ||
'campaign_id' => $campaignID, | ||
'soft_credit' => [ | ||
'1' => [ | ||
'contact_id' => $this->contacts['carol']['id'], | ||
|
@@ -281,7 +286,10 @@ public function testTokenRendering(): void { | |
non_deductible_amount = {contribution.non_deductible_amount} | ||
total_amount = {contribution.total_amount} | ||
net_amount = {contribution.net_amount} | ||
fee_amount = {contribution.fee_amount}'; | ||
fee_amount = {contribution.fee_amount} | ||
campaign_id = {contribution.campaign_id} | ||
campaign name = {contribution.campaign_id:name} | ||
campaign label = {contribution.campaign_id:label}'; | ||
|
||
$this->schedule->save(); | ||
$this->callAPISuccess('job', 'send_reminder', []); | ||
|
@@ -305,6 +313,9 @@ public function testTokenRendering(): void { | |
'total_amount = € 100.00', | ||
'net_amount = € 95.00', | ||
'fee_amount = € 5.00', | ||
'campaign_id = 1', | ||
'campaign name = big_campaign', | ||
'campaign label = Campaign', | ||
]; | ||
$this->mut->checkMailLog($expected); | ||
|
||
|
@@ -337,6 +348,9 @@ public function testTokenRendering(): void { | |
'total_amount = € 100.00', | ||
'net_amount = € 95.00', | ||
'fee_amount = € 5.00', | ||
'campaign_id = 1', | ||
'campaign name = big_campaign', | ||
'campaign label = Campaign', | ||
]; | ||
foreach ($expected as $string) { | ||
$this->assertStringContainsString($string, $contributionDetails[$this->contacts['alice']['id']]['html']); | ||
|
@@ -354,6 +368,21 @@ public function testTokenRendering(): void { | |
'contribution_status_id:label', | ||
]; | ||
$processor = new CRM_Contribute_Tokens(); | ||
$legacyTokens = []; | ||
$realLegacyTokens = []; | ||
foreach (CRM_Core_SelectValues::contributionTokens() as $token => $label) { | ||
$legacyTokens[substr($token, 14, -1)] = $label; | ||
if (strpos($token, ':') === FALSE) { | ||
$realLegacyTokens[substr($token, 14, -1)] = $label; | ||
} | ||
} | ||
$fields = (array) Contribution::getFields()->addSelect('name', 'title')->execute()->indexBy('name'); | ||
$allFields = []; | ||
foreach ($fields as $field) { | ||
$allFields[$field['name']] = $field['title']; | ||
} | ||
// $this->assertEquals($realLegacyTokens, $allFields); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is commented out because it is not true yet & I want to discuss whether it should be TRUE |
||
$this->assertEquals($legacyTokens, $processor->tokenNames); | ||
foreach ($tokens as $token) { | ||
$this->assertEquals(CRM_Core_SelectValues::contributionTokens()['{contribution.' . $token . '}'], $processor->tokenNames[$token]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note I manually tested that this token still works in the original legacy flow - although it is no longer advertised and it never worked in the scheduled reminders flow. This change just stops it from being advertised