diff --git a/tests/src/FunctionalJavascript/ContributionIatsTest.php b/tests/src/FunctionalJavascript/ContributionIatsTest.php index 55bd1241a..7807ac423 100644 --- a/tests/src/FunctionalJavascript/ContributionIatsTest.php +++ b/tests/src/FunctionalJavascript/ContributionIatsTest.php @@ -256,7 +256,7 @@ public function testSubmitContribution() { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $billingValues = [ @@ -463,7 +463,7 @@ public function testSubmitRecurringContribution() { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $billingValues = [ @@ -529,7 +529,7 @@ public function testSubmitRecurringContribution() { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $billingValues = [ diff --git a/tests/src/FunctionalJavascript/EventTest.php b/tests/src/FunctionalJavascript/EventTest.php index 068c58d82..7ff9de9a2 100644 --- a/tests/src/FunctionalJavascript/EventTest.php +++ b/tests/src/FunctionalJavascript/EventTest.php @@ -189,7 +189,7 @@ function testSubmitEventParticipant() { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $billingValues = [ diff --git a/tests/src/FunctionalJavascript/MembershipSubmissionTest.php b/tests/src/FunctionalJavascript/MembershipSubmissionTest.php index df126cca8..0287a4421 100644 --- a/tests/src/FunctionalJavascript/MembershipSubmissionTest.php +++ b/tests/src/FunctionalJavascript/MembershipSubmissionTest.php @@ -63,7 +63,7 @@ function testSubmitMembershipAutoRenew() { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $billingValues = [ diff --git a/tests/src/FunctionalJavascript/MultiCustomFieldsSubmissionTest.php b/tests/src/FunctionalJavascript/MultiCustomFieldsSubmissionTest.php index a654a808f..9da9d6cdd 100644 --- a/tests/src/FunctionalJavascript/MultiCustomFieldsSubmissionTest.php +++ b/tests/src/FunctionalJavascript/MultiCustomFieldsSubmissionTest.php @@ -152,7 +152,7 @@ public function testAnonymousSubmitWithContribution() { $this->getSession()->getPage()->fillField('Card Number', '4222222222222220'); $this->getSession()->getPage()->fillField('Security Code', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); $this->getSession()->getPage()->pressButton('Submit'); diff --git a/tests/src/FunctionalJavascript/WebformCivicrmTestBase.php b/tests/src/FunctionalJavascript/WebformCivicrmTestBase.php index 9631e6936..e9376fb57 100644 --- a/tests/src/FunctionalJavascript/WebformCivicrmTestBase.php +++ b/tests/src/FunctionalJavascript/WebformCivicrmTestBase.php @@ -720,7 +720,7 @@ protected function fillCardAndSubmit($billingValues = []) { $this->assertSession()->waitForField('credit_card_number'); $this->getSession()->getPage()->fillField('credit_card_number', '4222222222222220'); $this->getSession()->getPage()->fillField('cvv2', '123'); - $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[m]', '11'); + $this->getSession()->getPage()->selectFieldOption($this->getCreditCardMonthFieldName(), '11'); $this_year = date('Y'); $this->getSession()->getPage()->selectFieldOption('credit_card_exp_date[Y]', $this_year + 1); @@ -804,4 +804,14 @@ protected function getLastSubmissionId(WebformInterface $webform) { return reset($submission_ids); } + /** + * Can remove this once only testing 5.65+ + */ + private function getCreditCardMonthFieldName(): string { + if (version_compare(\CRM_Core_BAO_Domain::version(), '5.65.alpha1', '<')) { + return 'credit_card_exp_date[M]'; + } + return 'credit_card_exp_date[m]'; + } + }