Skip to content

Commit

Permalink
BcUtil::retry() ユニットテスト (#3830)
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 Sep 23, 2024
1 parent 5b65305 commit d45a506
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 @@ -2015,6 +2015,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 @@ -1241,6 +1241,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 d45a506

Please sign in to comment.