From cd355351eda2f06c8af2f1ac8e59b45ac06c8630 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Wed, 13 Mar 2019 14:00:14 +0000 Subject: [PATCH] Add a class to handle test entities consistently --- CRM/Activity/Selector/Search.php | 2 +- CRM/Contribute/BAO/ContributionSoft.php | 2 +- .../Page/ContributionRecurPayments.php | 3 + CRM/Core/TestEntity.php | 58 +++++++++++++++++++ CRM/Event/Form/ParticipantView.php | 2 +- CRM/Event/Selector/Search.php | 2 +- CRM/Member/Form/MembershipView.php | 2 +- CRM/Member/Selector/Search.php | 2 +- CRM/Pledge/Selector/Search.php | 2 +- .../WebTest/Event/AddParticipationTest.php | 2 +- 10 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 CRM/Core/TestEntity.php diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index 0d9e36c5d1..f6de0e43dd 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -310,7 +310,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM $accessMailingReport = FALSE; $activityTypeId = $row['activity_type_id']; if ($row['activity_is_test']) { - $row['activity_type'] = $row['activity_type'] . " (test)"; + $row['activity_type'] = CRM_Core_TestEntity::appendTestText($row['activity_type']); } $row['mailingId'] = ''; if ( diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 1f6671cb3d..8b7e1ec8c9 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -520,7 +520,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $result[$cs->id]['links'] = CRM_Core_Action::formLink($links, NULL, $replace); if ($isTest) { - $result[$cs->id]['contribution_status'] = $result[$cs->id]['contribution_status'] . '
(test)'; + $result[$cs->id]['contribution_status'] = CRM_Core_TestEntity::appendTestText($result[$cs->id]['contribution_status']); } } return $result; diff --git a/CRM/Contribute/Page/ContributionRecurPayments.php b/CRM/Contribute/Page/ContributionRecurPayments.php index 0410bdca3b..0237481dbf 100644 --- a/CRM/Contribute/Page/ContributionRecurPayments.php +++ b/CRM/Contribute/Page/ContributionRecurPayments.php @@ -53,6 +53,9 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { $this->insertStatusLabels($contribution); $this->insertContributionActions($contribution); + if ($contribution['is_test']) { + $contribution['financial_type'] = CRM_Core_TestEntity::appendTestText($contribution['financial_type']); + } $relatedContributions[] = $contribution; } diff --git a/CRM/Core/TestEntity.php b/CRM/Core/TestEntity.php new file mode 100644 index 0000000000..ee288dea1a --- /dev/null +++ b/CRM/Core/TestEntity.php @@ -0,0 +1,58 @@ +participant_id; diff --git a/CRM/Member/Form/MembershipView.php b/CRM/Member/Form/MembershipView.php index 7274bba59a..b5ac847010 100644 --- a/CRM/Member/Form/MembershipView.php +++ b/CRM/Member/Form/MembershipView.php @@ -398,7 +398,7 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, } if (!empty($values['is_test'])) { - $values['membership_type'] .= ' (test) '; + $values['membership_type'] = CRM_Core_TestEntity::appendTestText($values['membership_type']); } $subscriptionCancelled = CRM_Member_BAO_Membership::isSubscriptionCancelled($this->membershipID); diff --git a/CRM/Member/Selector/Search.php b/CRM/Member/Selector/Search.php index f46782627a..0d7c3639c0 100644 --- a/CRM/Member/Selector/Search.php +++ b/CRM/Member/Selector/Search.php @@ -377,7 +377,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C $row['campaign_id'] = $result->member_campaign_id; if (!empty($row['member_is_test'])) { - $row['membership_type'] = $row['membership_type'] . " (test)"; + $row['membership_type'] = CRM_Core_TestEntity::appendTestText($row['membership_type']); } $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->membership_id; diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index c7c75ce36d..f7548ed4d7 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -326,7 +326,7 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { } // append (test) to status label if (!empty($row['pledge_is_test'])) { - $row['pledge_status'] .= ' (test)'; + $row['pledge_status'] = CRM_Core_TestEntity::appendTestText($row['pledge_status']); } $hideOption = array(); diff --git a/tests/phpunit/WebTest/Event/AddParticipationTest.php b/tests/phpunit/WebTest/Event/AddParticipationTest.php index 0c21bd9286..044dd24d32 100644 --- a/tests/phpunit/WebTest/Event/AddParticipationTest.php +++ b/tests/phpunit/WebTest/Event/AddParticipationTest.php @@ -342,7 +342,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $this->clickLink("_qf_Search_refresh", "participantSearch"); //verifying the registered participants - $status = "Registered (test)"; + $status = CRM_Core_TestEntity::appendTestText("Registered"); foreach ($contacts as $contact) { $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$contact['sort_name']}']/../../td[9]", preg_quote($status)); -- 2.25.1