diff options
author | Joas Schilling <coding@schilljs.com> | 2024-01-26 16:16:37 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-01-26 16:16:37 +0100 |
commit | d086b6c81d32c83a0bd480cc29819a4d5e1cc425 (patch) | |
tree | 42ef13cfe2411b4594a9aec581b5c0373e7876f2 /apps/dav | |
parent | 6dffc9bc17bd494de4e9b6c1d51d9707c2a5b0b2 (diff) | |
download | nextcloud-server-d086b6c81d32c83a0bd480cc29819a4d5e1cc425.tar.gz nextcloud-server-d086b6c81d32c83a0bd480cc29819a4d5e1cc425.zip |
fix(tests): Make PHP 8.1.2 with Datetime Diff Bug pass the notifier test
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php index 08677d20267..10c421921b0 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php @@ -142,6 +142,14 @@ class NotifierTest extends TestCase { $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 [ [ @@ -150,7 +158,7 @@ class NotifierTest extends TestCase { '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, @@ -172,7 +180,7 @@ class NotifierTest extends TestCase { '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, @@ -281,7 +289,7 @@ class NotifierTest extends TestCase { $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); |