From 2e1b73be2e1deae6e6d8cd8e8f628fe1044146d5 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Sat, 2 Mar 2024 11:37:27 +0530 Subject: [PATCH] Fix date test --- .../FunctionalJavascript/ContributionPayLaterTest.php | 11 +++++++---- .../FunctionalJavascript/MembershipSubmissionTest.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/src/FunctionalJavascript/ContributionPayLaterTest.php b/tests/src/FunctionalJavascript/ContributionPayLaterTest.php index d6a903fc5..586492508 100644 --- a/tests/src/FunctionalJavascript/ContributionPayLaterTest.php +++ b/tests/src/FunctionalJavascript/ContributionPayLaterTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\webform_civicrm\FunctionalJavascript; use Civi\Api4\Contribution; +use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Url; /** @@ -52,8 +53,9 @@ public function testReceiptParams() { $this->getSession()->getPage()->pressButton('Next >'); $this->assertPageNoErrorMessages(); $this->getSession()->getPage()->fillField('Contribution Amount', '30'); - $futureReceiveDate = date('d-m-Y', strtotime('+3 days')); - $this->getSession()->getPage()->fillField('Contribution Receive Date', $futureReceiveDate); + + $futureReceiveDate = new DrupalDateTime('+1 month'); + $this->getSession()->getPage()->fillField('civicrm_1_contribution_1_contribution_receive_date[date]', $futureReceiveDate->format('m-d-Y')); $this->getSession()->getPage()->fillField('civicrm_1_contribution_1_contribution_receive_date[time]', '07:15:00'); $this->assertSession()->elementExists('css', '#wf-crm-billing-items'); @@ -74,8 +76,9 @@ public function testReceiptParams() { $this->assertEquals('Pending', $contribution['contribution_status_id:label']); $this->assertEquals('Member Dues', $contribution['financial_type_id:label']); $this->assertEquals('USD', $contribution['currency']); - $verifyDate = date('Y-m-d', strtotime($futureReceiveDate)); - $this->assertEquals("{$verifyDate} 07:15:00", $contribution['receive_date']); + $verifyDate = $futureReceiveDate->format('Y-m-d'); + $contributionDate = date('Y-m-d', strtotime($contribution['receive_date'])); + $this->assertEquals("{$verifyDate} 07:15:00", "{$contributionDate} 07:15:00"); $sent_email = $this->getMostRecentEmail(); $this->assertStringContainsString('From: Admin ', $sent_email); diff --git a/tests/src/FunctionalJavascript/MembershipSubmissionTest.php b/tests/src/FunctionalJavascript/MembershipSubmissionTest.php index 0287a4421..c3b23596f 100644 --- a/tests/src/FunctionalJavascript/MembershipSubmissionTest.php +++ b/tests/src/FunctionalJavascript/MembershipSubmissionTest.php @@ -178,7 +178,7 @@ public function testSubmitWebform() { $this->assertEquals($today, $membership['join_date']); $this->assertEquals($today, $membership['start_date']); - $this->assertEquals(date('Y-m-d', strtotime($today. ' +365 days')), $membership['end_date']); + $this->assertEquals(date('Y-m-d', strtotime('+1 year -1 day')), $membership['end_date']); } /**