Skip to content

Commit

Permalink
BcUtil::checkTime() のユニットテスト (#3419)
Browse files Browse the repository at this point in the history
Co-authored-by: Đỗ Văn Hùng <[email protected]>
  • Loading branch information
HungDV2022 and dovanhung authored May 17, 2024
1 parent afaadb8 commit e0481e3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/Utility/BcUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,7 @@ public static function isDebug(): bool
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public static function checkTime($hour, $min, $sec = null): bool
{
Expand Down
31 changes: 31 additions & 0 deletions plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit e0481e3

Please sign in to comment.