Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(tests): Make PHP 8.1.2 with Datetime Diff Bug pass the notifier test
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 26, 2024
commit d086b6c81d32c83a0bd480cc29819a4d5e1cc425
14 changes: 11 additions & 3 deletions apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ public function testPrepareWrongSubject(): void {
$this->notifier->prepare($notification, 'en');
}

private static function hasPhpDatetimeDiffBug(): bool {
$d1 = \DateTime::createFromFormat(\DateTimeInterface::ATOM, '2023-11-22T11:52:00+01:00');
$d2 = new \DateTime('2023-11-22T10:52:03', new \DateTimeZone('UTC'));

// The difference is 3 seconds, not -1year+11months+…
return $d1->diff($d2)->y < 0;
}

public function dataPrepare(): array {
return [
[
Expand All @@ -150,7 +158,7 @@ public function dataPrepare(): array {
'title' => 'Title of this event',
'start_atom' => '2005-08-15T15:52:01+02:00'
],
'Title of this event (in 1 hour, 52 minutes)',
self::hasPhpDatetimeDiffBug() ? 'Title of this event' : 'Title of this event (in 1 hour, 52 minutes)',
[
'title' => 'Title of this event',
'description' => null,
Expand All @@ -172,7 +180,7 @@ public function dataPrepare(): array {
'title' => 'Title of this event',
'start_atom' => '2005-08-15T13:00:00+02:00',
],
'Title of this event (1 hour ago)',
self::hasPhpDatetimeDiffBug() ? 'Title of this event' : 'Title of this event (1 hour ago)',
[
'title' => 'Title of this event',
'description' => null,
Expand Down Expand Up @@ -281,7 +289,7 @@ public function testPassedEvent(): void {

$notification->expects($this->once())
->method('setParsedSubject')
->with('Title of this event (6 hours ago)')
->with(self::hasPhpDatetimeDiffBug() ? 'Title of this event' : 'Title of this event (6 hours ago)')
->willReturnSelf();

$this->expectException(AlreadyProcessedException::class);
Expand Down