@@ -87,8 +87,6 @@ public function testStartRunning()
8787 $ this ->assertNotNull ($ container ['Id ' ]);
8888 $ this ->assertNull ($ container ['Warnings ' ]);
8989
90- $ start = microtime (true );
91-
9290 $ promise = $ this ->client ->containerStart ($ container ['Id ' ]);
9391 $ ret = Block \await ($ promise , $ this ->loop );
9492
@@ -177,7 +175,7 @@ public function testExecStringCommandWithOutputWhileRunning($container)
177175 */
178176 public function testExecStreamOutputInMultipleChunksWhileRunning ($ container )
179177 {
180- $ promise = $ this ->client ->execCreate ($ container , 'echo -n hello && sleep 0 && echo -n world ' );
178+ $ promise = $ this ->client ->execCreate ($ container , 'echo -n hello && sleep 0.2 && echo -n world ' );
181179 $ exec = Block \await ($ promise , $ this ->loop );
182180
183181 $ this ->assertTrue (is_array ($ exec ));
@@ -343,23 +341,32 @@ public function testImageTag()
343341 {
344342 // create new tag "bb:now" on "busybox:latest"
345343 $ promise = $ this ->client ->imageTag ('busybox ' , 'bb ' , 'now ' );
346- $ ret = Block \await ($ promise , $ this ->loop );
344+ Block \await ($ promise , $ this ->loop );
347345
348346 // delete tag "bb:now" again
349347 $ promise = $ this ->client ->imageRemove ('bb:now ' );
350- $ ret = Block \await ($ promise , $ this ->loop );
348+ Block \await ($ promise , $ this ->loop );
351349 }
352350
353351 public function testImageCreateStreamMissingWillEmitJsonError ()
354352 {
353+ $ promise = $ this ->client ->version ();
354+ $ version = Block \await ($ promise , $ this ->loop );
355+
356+ // old API reports a progress with error message, newer API just returns 404 right away
357+ // https://docs.docker.com/engine/api/version-history/
358+ $ old = $ version ['ApiVersion ' ] < '1.22 ' ;
359+
355360 $ stream = $ this ->client ->imageCreateStream ('clue/does-not-exist ' );
356361
357362 // one "progress" event, but no "data" events
358- $ stream ->on ('progress ' , $ this ->expectCallableOnce ());
363+ $ old && $ stream ->on ('progress ' , $ this ->expectCallableOnce ());
364+ $ old || $ stream ->on ('progress ' , $ this ->expectCallableNever ());
359365 $ stream ->on ('data ' , $ this ->expectCallableNever ());
360366
361367 // will emit "error" with JsonProgressException and close
362- $ stream ->on ('error ' , $ this ->expectCallableOnceParameter ('Clue\React\Docker\Io\JsonProgressException ' ));
368+ $ old && $ stream ->on ('error ' , $ this ->expectCallableOnceParameter ('Clue\React\Docker\Io\JsonProgressException ' ));
369+ $ old || $ stream ->on ('error ' , $ this ->expectCallableOnceParameter ('Clue\React\Buzz\Message\ResponseException ' ));
363370 $ stream ->on ('close ' , $ this ->expectCallableOnce ());
364371
365372 $ this ->loop ->run ();
0 commit comments