Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
1447d9d2
Commit
1447d9d2
authored
1 year ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Handle timezones in tests
parent
479c13f5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!217
Implement Stripe Checkout (with support for SEPA and ACH)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/phpunit/CRM/Stripe/BaseTest.php
+23
-0
23 additions, 0 deletions
tests/phpunit/CRM/Stripe/BaseTest.php
tests/phpunit/CRM/Stripe/IpnTest.php
+2
-2
2 additions, 2 deletions
tests/phpunit/CRM/Stripe/IpnTest.php
with
25 additions
and
2 deletions
tests/phpunit/CRM/Stripe/BaseTest.php
+
23
−
0
View file @
1447d9d2
...
...
@@ -175,6 +175,29 @@ abstract class CRM_Stripe_BaseTest extends \PHPUnit\Framework\TestCase implement
$this
->
createPaymentProcessor
();
}
/**
* When storing DateTime in database we have to convert to local timezone when running tests
* Used for checking that available_on custom field is set.
*
* @param string $dateInUTCTimezone eg. '2023-06-10 20:05:05'
*
* @return string
* @throws \Exception
*/
public
function
getDateinCurrentTimezone
(
string
$dateInUTCTimezone
)
{
// create a $dt object with the UTC timezone
$dt
=
new
DateTime
(
$dateInUTCTimezone
,
new
DateTimeZone
(
'UTC'
));
// get the local timezone
$loc
=
(
new
DateTime
)
->
getTimezone
();
// change the timezone of the object without changing its time
$dt
->
setTimezone
(
$loc
);
// format the datetime
return
$dt
->
format
(
'Y-m-d H:i:s'
);
}
/**
* Submit to stripe
*
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Stripe/IpnTest.php
+
2
−
2
View file @
1447d9d2
...
...
@@ -332,7 +332,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
// Check we set some values on the FinancialTrxn (payment)
$this
->
checkFinancialTrxn
([
'Payment_details.available_on'
=>
'2023-06-10 2
1
:05:05'
,
'Payment_details.available_on'
=>
$this
->
getDateinCurrentTimezone
(
'2023-06-10 2
0
:05:05'
)
,
'fee_amount'
=>
11.90
,
'total_amount'
=>
$this
->
total
,
'order_reference'
=>
'ch_mock'
,
...
...
@@ -747,7 +747,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
// Check we set some values on the FinancialTrxn (payment)
$this
->
checkFinancialTrxn
([
'Payment_details.available_on'
=>
'2023-06-10 2
1
:05:05'
,
'Payment_details.available_on'
=>
$this
->
getDateinCurrentTimezone
(
'2023-06-10 2
0
:05:05'
)
,
'fee_amount'
=>
11.90
,
'total_amount'
=>
$this
->
total
,
'order_reference'
=>
'in_mock_2'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment