From a51313543db74859691529ef5aff9ccab64c4a63 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Thu, 27 Apr 2017 18:34:27 -0500 Subject: [PATCH] Add test cases for JDate constructor demonstrating broken timezone handling --- .../libraries/joomla/date/JDateTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/unit/suites/libraries/joomla/date/JDateTest.php b/tests/unit/suites/libraries/joomla/date/JDateTest.php index 57de18d5fb9f7..bb019547deb0b 100644 --- a/tests/unit/suites/libraries/joomla/date/JDateTest.php +++ b/tests/unit/suites/libraries/joomla/date/JDateTest.php @@ -541,6 +541,44 @@ public function test__construct($date, $tz, $expectedTime) ); } + /** + * Testing the Constructor for now when not using UTC + * + * @return void + * + * @since __DEPLOY_VERSION__ + * @covers JDate::__construct + */ + public function test__constructForNowWhenNotUsingUTC() + { + $jdate = new JDate('now', new DateTimeZone('US/Central')); + $phpdate = new DateTime('now', new DateTimeZone('US/Central')); + + $this->assertSame( + $jdate->format('D m/d/Y H:i'), + $phpdate->format('D m/d/Y H:i') + ); + } + + /** + * Testing the Constructor for now when using UTC + * + * @return void + * + * @since __DEPLOY_VERSION__ + * @covers JDate::__construct + */ + public function test__constructForNowWhenUsingUTC() + { + $jdate = new JDate('now', new DateTimeZone('UTC')); + $phpdate = new DateTime('now', new DateTimeZone('UTC')); + + $this->assertSame( + $jdate->format('D m/d/Y H:i'), + $phpdate->format('D m/d/Y H:i') + ); + } + /** * Testing the Constructor *