From 90530b8758e7d9ed88f9fc222b6eeb8a758ba4c5 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 1 Jan 2020 16:22:32 +1300 Subject: [PATCH] 2020 test fixes. We have 8 tests failing that seem to be due to 2020 starting. This fixes 2 --- CRM/Core/Payment/Dummy.php | 3 +-- CRM/Member/Form/MembershipRenewal.php | 1 + .../phpunit/CRM/Event/Form/Registration/ConfirmTest.php | 4 ++-- tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php | 9 +++++---- tests/phpunit/CRM/Member/Form/MembershipTest.php | 3 +-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index b2b66125fbdd..d7c39838ee89 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -96,8 +96,7 @@ public function doDirectPayment(&$params) { // be more complete. if (!empty($params['credit_card_exp_date']['Y']) && date('Y') > CRM_Core_Payment_Form::getCreditCardExpirationYear($params)) { - $error = new CRM_Core_Error(ts('transaction failed')); - return $error; + throw new PaymentProcessorException(ts('Invalid expiry date')); } //end of hook invocation if (!empty($this->_doDirectPaymentResult)) { diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 36aecfce2d5a..f6e50c2d87cb 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -477,6 +477,7 @@ public function postProcess() { * This function is also accessed by a unit test. * * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ protected function submit() { $this->storeContactFields($this->_params); diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index ba5884f24a24..cae3633d36ad 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -124,7 +124,7 @@ public function testPaidSubmit($thousandSeparator) { 'cvv2' => '123', 'credit_card_exp_date' => [ 'M' => '1', - 'Y' => '2019', + 'Y' => date('Y') + 1, ], 'credit_card_type' => 'Visa', 'billing_first_name' => 'p', @@ -207,7 +207,7 @@ public function testPaidSubmit($thousandSeparator) { ], $entityFinancialTrxns[2], ['id', 'entity_id']); $mut->checkMailLog([ 'Event Information and Location', 'Registration Confirmation - Annual CiviCRM meet', - 'Expires: January 2019', + 'Expires: January ' . (date('Y') + 1), 'Visa', '************1111', 'This is a confirmation that your registration has been received and your status has been updated to Registered', diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index 197bd8cd7e50..2cdce1e80616 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -234,8 +234,7 @@ public function testSubmitRecur() { 'cvv2' => '123', 'credit_card_exp_date' => [ 'M' => '9', - // TODO: Future proof - 'Y' => '2019', + 'Y' => date('Y') + 1, ], 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -357,6 +356,9 @@ public function testSubmitRecurCompleteInstant() { * @param string $thousandSeparator * * @dataProvider getThousandSeparators + * + * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ public function testSubmitRecurCompleteInstantWithMail($thousandSeparator) { $this->setCurrencySeparators($thousandSeparator); @@ -614,8 +616,7 @@ protected function getBaseSubmitParams() { 'cvv2' => '123', 'credit_card_exp_date' => [ 'M' => '9', - // TODO: Future proof - 'Y' => '2019', + 'Y' => date('Y') + 1, ], 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 63911ce42874..a34c3cfa5802 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -1195,8 +1195,7 @@ protected function getBaseSubmitParams() { 'cvv2' => '123', 'credit_card_exp_date' => [ 'M' => '9', - // TODO: Future proof - 'Y' => '2019', + 'Y' => date('Y') + 1, ], 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test',