File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 3
3
namespace TitasGailius \Terminal ;
4
4
5
5
use DateTime ;
6
+ use Exception ;
6
7
use DateInterval ;
7
8
use BadMethodCallException ;
8
- use Exception ;
9
9
use InvalidArgumentException ;
10
10
use Symfony \Component \Process \Process ;
11
11
@@ -200,7 +200,7 @@ public function inBackground()
200
200
* @param int $sleep
201
201
* @return $this
202
202
*/
203
- public function retries (int $ times , int $ sleep )
203
+ public function retries (int $ times , int $ sleep = 0 )
204
204
{
205
205
$ this ->retries = [$ times , $ sleep ];
206
206
Original file line number Diff line number Diff line change @@ -242,6 +242,23 @@ public function testBuilderProxy()
242
242
$ this ->assertEquals (123 , $ builder ->getPid ());
243
243
}
244
244
245
+ /**
246
+ * Test that it retries a failed command.
247
+ *
248
+ * @return void
249
+ */
250
+ public function testRetry ()
251
+ {
252
+ $ builder = $ this ->builderWithMockedProccess (function ($ mock ) {
253
+ $ mock ->shouldReceive ('isSuccessful ' )
254
+ ->times (3 )
255
+ ->andReturn (false , false , true );
256
+ });
257
+
258
+ $ builder ->retries (3 )
259
+ ->execute ('echo Hello, World ' );
260
+ }
261
+
245
262
/**
246
263
* Create a new builder instance with a mocked process instance.
247
264
*
You can’t perform that action at this time.
0 commit comments