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 *