Skip to content

Commit c834064

Browse files
committed
bug #54712 [RemoteEvent] Fix date parsing remote event payload converter (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- [RemoteEvent] Fix date parsing remote event payload converter | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT [AppVeyor fails](https://ci.appveyor.com/project/fabpot/symfony/builds/49679328) on some date expectation: ```diff There was 1 failure: 1) Symfony\Component\Mailer\Bridge\Resend\Tests\Webhook\ResendRequestParserTest::testParse with data set "C:\projects\symfony\src\Symfony\Component\Mailer\Bridge\Resend\Tests\Webhook/Fixtures\sent.json" ('{\n "created_at": "2024-04..."\n}\n', Symfony\Component\RemoteEvent\Event\Mailer\MailerDeliveryEvent Object (...)) Failed asserting that two objects are equal. --- Expected +++ Actual @@ @@ 'name' => 'received' 'id' => '172c41ce-ba6d-4281-8a7a-541faa725748' 'payload' => Array (...) - 'date' => 2024-04-08T09:43:09.500000-0700 + 'date' => 2024-04-08T09:43:09.500000+0000 'email' => 'test@example.com' 'metadata' => Array (...) 'tags' => Array () 'reason' => '' ) C:\projects\symfony\src\Symfony\Component\Webhook\Test\AbstractRequestParserTestCase.php:32 ``` Indeed, this can happen depending on your configuration because the timezone is not set when creating fixtures, which leads to a difference, as shown here: https://3v4l.org/iFBMq. Defining the timezone in the parsing should solve this flaky test. Commits ------- 98a7214 [Mailer] Fix date parsing remote event payload converter
2 parents 65ccca0 + 98a7214 commit c834064

File tree

12 files changed

+12
-12
lines changed

12 files changed

+12
-12
lines changed

src/Symfony/Component/Mailer/Bridge/MailerSend/RemoteEvent/MailerSendPayloadConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function convert(array $payload): AbstractMailerEvent
4343
$event = new MailerEngagementEvent($name, $this->getMessageId($payload), $payload);
4444
}
4545

46-
if (!$date = \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', $payload['created_at'])) {
46+
if (!$date = \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', $payload['created_at'])) {
4747
throw new ParseException(sprintf('Invalid date "%s".', $payload['created_at']));
4848
}
4949

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/clicked.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
'ip' => '127.0.0.1',
1010
'url' => 'https://www.mailersend.com'
1111
]);
12-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
12+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1313

1414
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/clicked_unique.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
'ip' => '127.0.0.1',
1010
'url' => 'https://www.mailersend.com'
1111
]);
12-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
12+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1313

1414
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/delivered.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
$wh->setTags(["test-tag"]);
88
$wh->setMetadata([]);
99
$wh->setReason('');
10-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
10+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1111

1212
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/hard_bounced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
$wh->setTags(["test-tag"]);
88
$wh->setMetadata([]);
99
$wh->setReason('Host or domain name not found');
10-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
10+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1111

1212
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/opened.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
$wh->setMetadata([
99
'ip' => '127.0.0.1'
1010
]);
11-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
11+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1212

1313
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/opened_unique.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
$wh->setMetadata([
99
'ip' => '127.0.0.1'
1010
]);
11-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
11+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1212

1313
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/sent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
$wh->setTags(["test-tag"]);
88
$wh->setMetadata([]);
99
$wh->setReason('');
10-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
10+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1111

1212
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/soft_bounced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
$wh->setTags(["test-tag"]);
88
$wh->setMetadata([]);
99
$wh->setReason('Unknown reason');
10-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
10+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1111

1212
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/spam_complaint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
$wh->setRecipientEmail('test@example.com');
77
$wh->setTags(["test-tag"]);
88
$wh->setMetadata([]);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1010

1111
return $wh;

src/Symfony/Component/Mailer/Bridge/MailerSend/Tests/Webhook/Fixtures/unsubscribed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
'reason' => 'NO_LONGER_WANT',
1010
'readable_reason' => 'I no longer want to receive these emails'
1111
]);
12-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-01-01T12:00:00.000000Z'));
12+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-01-01T12:00:00.000000Z'));
1313

1414
return $wh;

src/Symfony/Component/Mailer/Bridge/Resend/Tests/Webhook/Fixtures/sent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
],
2222
]);
2323
$wh->setReason('');
24-
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u\Z', '2024-04-08T09:43:09.500000Z'));
24+
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2024-04-08T09:43:09.500000Z'));
2525

2626
return $wh;

0 commit comments

Comments
 (0)