Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BcUtil::checkTime() のユニットテスト #3419

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2074,6 +2074,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
Loading