dev/core#2650 Add support for names & labels for token pseudoconstants
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 27 Jul 2021 07:40:13 +0000 (19:40 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 28 Jul 2021 01:02:38 +0000 (13:02 +1200)
commit9b3cb77dca4db85658e62b2b1b7f2d24958a9714
treebbfc243f7972b33371461c9067fe5ad2dc166a3c
parent8e851c62d2bd6ef0a1d52dfcc62d4d2f4331f2ed
dev/core#2650 Add support for names & labels for token pseudoconstants

This is per https://lab.civicrm.org/dev/core/-/issues/2650 -
it
- ensures that the 4 existing functions that deal with tokens handle tokens for the
name and label for the (only) field that has had this treatment so far -contribution_status_id

Hence both CRM_Core_SelecetValues::contributionTokens and CRM_Contribute_Tokens->tokenNames
are tested to ensure they both return the same keys and labels for
{contribution.contribution_status_id}
{contribution.contribution_status_id:name}
{contribution.contribution_status_id:label}

And both rendering CRM_Contribute_Tokens via scheduled reminders and
using CRM_Contribute_BAO_Contribution::replaceContributionTokens are tested to ensure
they render them the same.

In the context of this PR no existing tokens are altered or removed & there is
only addition. However, the next step would be to remove the following token
from  {contribution.status}. Since there is no UI availability
of this token it is likely unused - but that step would entail an upgrade
script to remove it from the saved scheduled reminders.

With those parts in place it should be possible to reconcile the remaining tokens,
lock that parity in with tests and move on to exposing the contribution tokens
to message templates.

It would be nice to fully remove CRM_Contribute_BAO_Contribution::replaceContributionTokens
or make it a wrapper for  - however, I fear that might be quite
challenging due to the way it's used with group bys & some pretty intense hackery.
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Tokens.php
CRM/Core/SelectValues.php
CRM/Utils/Token.php
tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php