From 9088326d66db217ead88e860ec5530201af580a0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 3 Aug 2021 20:56:26 +0900 Subject: [PATCH] Add unit tests for ce76501f2 --- tests/unit/framework/DateTimeTest.php | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/unit/framework/DateTimeTest.php b/tests/unit/framework/DateTimeTest.php index 27d8021c2..8ad7d5f62 100644 --- a/tests/unit/framework/DateTimeTest.php +++ b/tests/unit/framework/DateTimeTest.php @@ -9,6 +9,7 @@ class DateTimeTest extends \Codeception\TestCase\Test // Add some dummy data to system configuration. Asia/Seoul offset is 32400. Rhymix\Framework\Config::set('locale.default_timezone', 'Asia/Seoul'); Rhymix\Framework\Config::set('locale.internal_timezone', 10800); + Context::getInstance(); Context::set('_default_timezone', $GLOBALS['_time_zone'] = 'Asia/Seoul'); // Set PHP time zone to the internal time zone. @@ -54,6 +55,22 @@ class DateTimeTest extends \Codeception\TestCase\Test Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } + public function testZtimeDateOnly() + { + $timestamp = -271641600; + + // Test ztime() when the internal time zone is different from the default time zone. + Rhymix\Framework\Config::set('locale.internal_timezone', 10800); + $this->assertEquals($timestamp, ztime('19610524')); + + // Test ztime() when the internal time zone is the same as the default time zone. + Rhymix\Framework\Config::set('locale.internal_timezone', 32400); + $this->assertEquals($timestamp, ztime('19610524')); + + // Restore the internal timezone. + Rhymix\Framework\Config::set('locale.internal_timezone', 10800); + } + public function testZdate() { $expected = '2016-01-29 01:53:20'; @@ -70,6 +87,22 @@ class DateTimeTest extends \Codeception\TestCase\Test Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } + public function testZdateDateOnly() + { + $expected = '1961-05-24'; + + // Test zdate() when the internal time zone is different from the default time zone. + Rhymix\Framework\Config::set('locale.internal_timezone', 10800); + $this->assertEquals($expected, zdate('19610524', 'Y-m-d')); + + // Test zdate() when the internal time zone is the same as the default time zone. + Rhymix\Framework\Config::set('locale.internal_timezone', 32400); + $this->assertEquals($expected, zdate('19610524', 'Y-m-d')); + + // Restore the internal timezone. + Rhymix\Framework\Config::set('locale.internal_timezone', 10800); + } + public function testGetInternalDateTime() { $timestamp = 1454000000;