From e4dac99aa02c552e7c8df0b8a2517a27e9d16eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 14 May 2024 10:49:29 +0900 Subject: [PATCH] =?UTF-8?q?BcUtil::checkTime()=20=E3=81=AE=E3=83=A6?= =?UTF-8?q?=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Utility/BcUtil.php | 1 + .../tests/TestCase/Utility/BcUtilTest.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/plugins/baser-core/src/Utility/BcUtil.php b/plugins/baser-core/src/Utility/BcUtil.php index 6005136370..8b0f611560 100644 --- a/plugins/baser-core/src/Utility/BcUtil.php +++ b/plugins/baser-core/src/Utility/BcUtil.php @@ -2074,6 +2074,7 @@ public static function isDebug(): bool * @return bool * @checked * @noTodo + * @unitTest */ public static function checkTime($hour, $min, $sec = null): bool { diff --git a/plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php b/plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php index 5e44262b96..9f43ac98df 100644 --- a/plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php +++ b/plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php @@ -1191,6 +1191,37 @@ public function testCreateRequest(): void $this->assertEquals('testGetRequest', $request->getSession()->read('test')); } + /** + * test checkTime + * + * @param $hour + * @param $min + * @param $sec + * @param $expect + * @dataProvider checkTimeDataProvider + */ + public function test_checkTime($hour, $min, $sec, $expect) + { + $rs = BcUtil::checkTime($hour, $min, $sec); + $this->assertEquals($expect, $rs); + } + + public static function checkTimeDataProvider() + { + return [ + [-1, 1, 1, false], //$hour < 0 return false + [24, 1, 1, false], //$hour > 23 return false + [23, -1, 1, false], //$min < 0 return false + [23, 60, 1, false], //$min > 59 return false + [23, 59, -1, false], //$sec < 0 return false + [23, 59, 60, false], //$sec > 59 return false + [23, 59, 59, true], //return true + [0, 0, 0, true], //return true + [0, 0, null, true], //return true + [23, 59, null, true], //return true + ]; + } + /** * Test getCurrentTheme *