Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 28, 2018
1 parent 6e921c1 commit 624fec4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Core/Retry/CommandRetry.php
Expand Up @@ -61,8 +61,8 @@ public function run(callable $action)
{
$retryCount = 0;
$lastException = null;
while ($this->retries > $retryCount) {
$retryCount++;

do {
try {
return $action();
} catch (Exception $e) {
Expand All @@ -71,7 +71,7 @@ public function run(callable $action)
throw $e;
}
}
}
} while ($this->retries > $retryCount++);

if ($lastException !== null) {
throw $lastException;
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Core/Retry/CommandRetryTest.php
Expand Up @@ -49,13 +49,13 @@ public function testRetry()
->method('shouldRetry')
->will($this->returnCallback(function ($e, $c) use ($exception, &$count) {
$this->assertSame($e, $exception);
$this->assertEquals($c, $count);
$this->assertEquals($c + 1, $count);

return true;
}));

$retry = new CommandRetry($strategy, 5);
$retry->run($action);
$this->assertEquals(4, $retry->run($action));
}

/**
Expand All @@ -72,7 +72,7 @@ public function testExceedAttempts()

$strategy = $this->getMockBuilder(RetryStrategyInterface::class)->getMock();
$strategy
->expects($this->exactly(3))
->expects($this->exactly(4))
->method('shouldRetry')
->will($this->returnCallback(function ($e) use ($exception) {
return true;
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/ConnectionTest.php
Expand Up @@ -1249,7 +1249,8 @@ public function testAutomaticReconnect()
->method('prepare')
->will($this->returnValue($statement));

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

/**
Expand Down

0 comments on commit 624fec4

Please sign in to comment.