Skip to content

Commit

Permalink
BcUtil::retry() ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Sep 20, 2024
1 parent d3f0488 commit ef040a5
Show file tree
Hide file tree
Showing 2 changed files with 16 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 @@ -2011,6 +2011,7 @@ public static function pairToAssoc()
* @throws Exception
* @checked
* @noTodo
* @unitTest
*/
public static function retry($times, callable $callback, $interval = 0)
{
Expand Down
15 changes: 15 additions & 0 deletions plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,21 @@ public function event1() {
$this->assertEmpty($listeners);
}

/**
* test retry
*/
public function testRetry()
{
//正常実行
$rs = BcUtil::retry(1, function () {return 2;}, 3);
$this->assertEquals(2, $rs);

//異常実行
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('リトライ回数は正の整数値で指定してください。');
BcUtil::retry(-1, function () {return 0;}, 1);
}

/**
* Test createRequest
*
Expand Down

0 comments on commit ef040a5

Please sign in to comment.