Skip to content

Commit

Permalink
Fix date test
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendrapurohit committed Mar 2, 2024
1 parent 87e481d commit 2e1b73b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/src/FunctionalJavascript/ContributionPayLaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\Tests\webform_civicrm\FunctionalJavascript;

use Civi\Api4\Contribution;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Url;

/**
Expand Down Expand Up @@ -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');
Expand All @@ -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 <[email protected]>', $sent_email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down

0 comments on commit 2e1b73b

Please sign in to comment.