From fe86f270cf2803684ec83acca68327680c7a9b7c Mon Sep 17 00:00:00 2001 From: webimpress Date: Tue, 25 Dec 2018 16:02:54 +0100 Subject: [PATCH] Fixed tests on PHP 7.2+ DateTime incorporates microseconds --- test/Header/DateTest.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/Header/DateTest.php b/test/Header/DateTest.php index 4980a36347..46daabe875 100644 --- a/test/Header/DateTest.php +++ b/test/Header/DateTest.php @@ -39,7 +39,13 @@ public function testDateFromTimeStringCreatesValidDateHeader() $date = new DateTime(null, new DateTimeZone('GMT')); $interval = $dateHeader->date()->diff($date, 1); - $this->assertSame('+12 hours 00 minutes 00 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + if (PHP_VERSION_ID >= 70200) { + $this->assertSame('+11 hours 59 minutes 59 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + $this->assertLessThan(1, $interval->f); + $this->assertGreaterThan(0, $interval->f); + } else { + $this->assertSame('+12 hours 00 minutes 00 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + } } public function testDateFromTimestampCreatesValidDateHeader() @@ -52,7 +58,13 @@ public function testDateFromTimestampCreatesValidDateHeader() $date = new DateTime(null, new DateTimeZone('GMT')); $interval = $dateHeader->date()->diff($date, 1); - $this->assertSame('+12 hours 00 minutes 00 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + if (PHP_VERSION_ID >= 70200) { + $this->assertSame('+11 hours 59 minutes 59 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + $this->assertLessThan(1, $interval->f); + $this->assertGreaterThan(0, $interval->f); + } else { + $this->assertSame('+12 hours 00 minutes 00 seconds', $interval->format('%R%H hours %I minutes %S seconds')); + } } public function testDateFromTimeStringDetectsBadInput()