File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ public function run(callable $action)
61
61
{
62
62
$ retryCount = 0 ;
63
63
$ lastException = null ;
64
- while ( $ this -> retries > $ retryCount ) {
65
- $ retryCount ++;
64
+
65
+ do {
66
66
try {
67
67
return $ action ();
68
68
} catch (Exception $ e ) {
@@ -71,7 +71,7 @@ public function run(callable $action)
71
71
throw $ e ;
72
72
}
73
73
}
74
- }
74
+ } while ( $ this -> retries > $ retryCount ++);
75
75
76
76
if ($ lastException !== null ) {
77
77
throw $ lastException ;
Original file line number Diff line number Diff line change @@ -49,13 +49,13 @@ public function testRetry()
49
49
->method ('shouldRetry ' )
50
50
->will ($ this ->returnCallback (function ($ e , $ c ) use ($ exception , &$ count ) {
51
51
$ this ->assertSame ($ e , $ exception );
52
- $ this ->assertEquals ($ c , $ count );
52
+ $ this ->assertEquals ($ c + 1 , $ count );
53
53
54
54
return true ;
55
55
}));
56
56
57
57
$ retry = new CommandRetry ($ strategy , 5 );
58
- $ retry ->run ($ action );
58
+ $ this -> assertEquals ( 4 , $ retry ->run ($ action) );
59
59
}
60
60
61
61
/**
@@ -72,7 +72,7 @@ public function testExceedAttempts()
72
72
73
73
$ strategy = $ this ->getMockBuilder (RetryStrategyInterface::class)->getMock ();
74
74
$ strategy
75
- ->expects ($ this ->exactly (3 ))
75
+ ->expects ($ this ->exactly (4 ))
76
76
->method ('shouldRetry ' )
77
77
->will ($ this ->returnCallback (function ($ e ) use ($ exception ) {
78
78
return true ;
Original file line number Diff line number Diff line change @@ -1249,7 +1249,8 @@ public function testAutomaticReconnect()
1249
1249
->method ('prepare ' )
1250
1250
->will ($ this ->returnValue ($ statement ));
1251
1251
1252
- $ this ->assertSame ($ statement , $ conn ->query ('SELECT 1 ' ));
1252
+ $ res = $ conn ->query ('SELECT 1 ' );
1253
+ $ this ->assertInstanceOf ('Cake\Database\StatementInterface ' , $ res );
1253
1254
}
1254
1255
1255
1256
/**
You can’t perform that action at this time.
0 commit comments