Browse Source

Fixed tests

Jose Lorenzo Rodriguez 8 years ago
parent
commit
624fec4ec3

+ 3 - 3
src/Core/Retry/CommandRetry.php

@@ -61,8 +61,8 @@ class CommandRetry
     {
         $retryCount = 0;
         $lastException = null;
-        while ($this->retries > $retryCount) {
-            $retryCount++;
+
+        do {
             try {
                 return $action();
             } catch (Exception $e) {
@@ -71,7 +71,7 @@ class CommandRetry
                     throw $e;
                 }
             }
-        }
+        } while ($this->retries > $retryCount++);
 
         if ($lastException !== null) {
             throw $lastException;

+ 3 - 3
tests/TestCase/Core/Retry/CommandRetryTest.php

@@ -49,13 +49,13 @@ class CommandRetryTest extends TestCase
             ->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));
     }
 
     /**
@@ -72,7 +72,7 @@ class CommandRetryTest extends TestCase
 
         $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;

+ 2 - 1
tests/TestCase/Database/ConnectionTest.php

@@ -1249,7 +1249,8 @@ class ConnectionTest extends TestCase
             ->method('prepare')
             ->will($this->returnValue($statement));
 
-        $this->assertSame($statement, $conn->query('SELECT 1'));
+        $res = $conn->query('SELECT 1');
+        $this->assertInstanceOf('Cake\Database\StatementInterface', $res);
     }
 
     /**