From 13b8485a8690f103bf19cba64879c218b102b726 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 20 Nov 2019 07:59:06 +0100 Subject: [PATCH] Fix #1943 Add example for H:s.vi (#1944) * Fix #1943 Add example for H:s.vi * Fix #1943 Drop support of .v for PHP < 7.3 * Fix test PHP < 7.2 compatibility --- tests/Carbon/IsTest.php | 5 +++++ tests/CarbonImmutable/IsTest.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/Carbon/IsTest.php b/tests/Carbon/IsTest.php index 34608426a1..e0749a3328 100644 --- a/tests/Carbon/IsTest.php +++ b/tests/Carbon/IsTest.php @@ -869,6 +869,11 @@ public function testHasFormat() $this->assertTrue(Carbon::hasFormat('2000-07-01T00:00:00+00:00', Carbon::ATOM)); $this->assertTrue(Carbon::hasFormat('Y-01-30\\', '\\Y-m-d\\\\')); + if (version_compare(PHP_VERSION, '7.3.0-dev', '>=')) { + // Due to https://bugs.php.net/bug.php?id=75577, proper "v" format support can only works from PHP 7.3.0. + $this->assertTrue(Carbon::hasFormat('2012-12-04 22:59.32130', 'Y-m-d H:s.vi')); + } + // Format failure $this->assertFalse(Carbon::hasFormat('1975-05-01', 'd m Y')); $this->assertFalse(Carbon::hasFormat('Foo 21st', 'D jS')); diff --git a/tests/CarbonImmutable/IsTest.php b/tests/CarbonImmutable/IsTest.php index 078e188437..4adf4b794f 100644 --- a/tests/CarbonImmutable/IsTest.php +++ b/tests/CarbonImmutable/IsTest.php @@ -878,6 +878,14 @@ public function testHasFormat() $this->assertTrue(Carbon::hasFormat('30/12/2019', 'd/m/Y')); $this->assertTrue(Carbon::hasFormat('Sun 21st', 'D jS')); + $this->assertTrue(Carbon::hasFormat('2000-07-01T00:00:00+00:00', DateTime::ATOM)); + $this->assertTrue(Carbon::hasFormat('Y-01-30\\', '\\Y-m-d\\\\')); + + if (version_compare(PHP_VERSION, '7.3.0-dev', '>=')) { + // Due to https://bugs.php.net/bug.php?id=75577, proper "v" format support can only works from PHP 7.3.0. + $this->assertTrue(Carbon::hasFormat('2012-12-04 22:59.32130', 'Y-m-d H:s.vi')); + } + // Format failure $this->assertFalse(Carbon::hasFormat('1975-05-01', 'd m Y')); $this->assertFalse(Carbon::hasFormat('Foo 21st', 'D jS'));