Skip to content

Commit 624fec4

Browse files
committed
Fixed tests
1 parent 6e921c1 commit 624fec4

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/Core/Retry/CommandRetry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function run(callable $action)
6161
{
6262
$retryCount = 0;
6363
$lastException = null;
64-
while ($this->retries > $retryCount) {
65-
$retryCount++;
64+
65+
do {
6666
try {
6767
return $action();
6868
} catch (Exception $e) {
@@ -71,7 +71,7 @@ public function run(callable $action)
7171
throw $e;
7272
}
7373
}
74-
}
74+
} while ($this->retries > $retryCount++);
7575

7676
if ($lastException !== null) {
7777
throw $lastException;

tests/TestCase/Core/Retry/CommandRetryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function testRetry()
4949
->method('shouldRetry')
5050
->will($this->returnCallback(function ($e, $c) use ($exception, &$count) {
5151
$this->assertSame($e, $exception);
52-
$this->assertEquals($c, $count);
52+
$this->assertEquals($c + 1, $count);
5353

5454
return true;
5555
}));
5656

5757
$retry = new CommandRetry($strategy, 5);
58-
$retry->run($action);
58+
$this->assertEquals(4, $retry->run($action));
5959
}
6060

6161
/**
@@ -72,7 +72,7 @@ public function testExceedAttempts()
7272

7373
$strategy = $this->getMockBuilder(RetryStrategyInterface::class)->getMock();
7474
$strategy
75-
->expects($this->exactly(3))
75+
->expects($this->exactly(4))
7676
->method('shouldRetry')
7777
->will($this->returnCallback(function ($e) use ($exception) {
7878
return true;

tests/TestCase/Database/ConnectionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,8 @@ public function testAutomaticReconnect()
12491249
->method('prepare')
12501250
->will($this->returnValue($statement));
12511251

1252-
$this->assertSame($statement, $conn->query('SELECT 1'));
1252+
$res = $conn->query('SELECT 1');
1253+
$this->assertInstanceOf('Cake\Database\StatementInterface', $res);
12531254
}
12541255

12551256
/**

0 commit comments

Comments
 (0)