@@ -190,7 +190,7 @@ public function testContainerLogsRejectsWhenInspectingContainerRejects()
190
190
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
191
191
}
192
192
193
- public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerResolvesWithTtyAndContainerLogsArePending ()
193
+ public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerResolvesWithTtyAndContainerLogsRequestIsPending ()
194
194
{
195
195
$ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
196
196
$ this ->browser ->expects ($ this ->exactly (2 ))->method ('get ' )->withConsecutive (
@@ -211,7 +211,7 @@ public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerRes
211
211
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
212
212
}
213
213
214
- public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerResolvesWithoutTtyAndContainerLogsArePending ()
214
+ public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerResolvesWithoutTtyAndContainerLogsRequestIsPending ()
215
215
{
216
216
$ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
217
217
$ this ->browser ->expects ($ this ->exactly (2 ))->method ('get ' )->withConsecutive (
@@ -232,7 +232,7 @@ public function testContainerLogsReturnsPendingPromiseWhenInspectingContainerRes
232
232
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
233
233
}
234
234
235
- public function testContainerLogsResolvesWhenInspectingContainerResolvesWithTtyAndContainerLogsResolves ()
235
+ public function testContainerLogsResolvesWhenInspectingContainerResolvesWithTtyAndContainerLogsRequestResolves ()
236
236
{
237
237
$ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
238
238
$ this ->browser ->expects ($ this ->exactly (2 ))->method ('get ' )->withConsecutive (
@@ -253,7 +253,7 @@ public function testContainerLogsResolvesWhenInspectingContainerResolvesWithTtyA
253
253
$ promise ->then ($ this ->expectCallableOnceWith ('output ' ), $ this ->expectCallableNever ());
254
254
}
255
255
256
- public function testContainerLogsStreamReturnStreamWhenInspectingContainerResolvesWithTtyAndContainerLogsResolves ()
256
+ public function testContainerLogsStreamReturnStreamWhenInspectingContainerResolvesWithTtyAndContainerLogsRequestResolves ()
257
257
{
258
258
$ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
259
259
$ this ->browser ->expects ($ this ->exactly (2 ))->method ('get ' )->withConsecutive (
@@ -379,6 +379,93 @@ public function testContainerUnpause()
379
379
$ this ->expectPromiseResolveWith ('' , $ this ->client ->containerUnpause (123 ));
380
380
}
381
381
382
+ public function testContainerAttachReturnsPendingPromiseWhenInspectingContainerIsPending ()
383
+ {
384
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (new \React \Promise \Promise (function () { }));
385
+
386
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('bufferedStream ' )->with ($ this ->isInstanceOf ('React\Stream\ReadableStreamInterface ' ))->willReturn (new \React \Promise \Promise (function () { }));
387
+
388
+ $ promise = $ this ->client ->containerAttach ('123 ' , true , false );
389
+
390
+ $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
391
+ }
392
+
393
+ public function testContainerAttachRejectsWhenInspectingContainerRejects ()
394
+ {
395
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (\React \Promise \reject (new \RuntimeException ()));
396
+
397
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('bufferedStream ' )->with ($ this ->isInstanceOf ('React\Stream\ReadableStreamInterface ' ))->willReturn (\React \Promise \reject (new \RuntimeException ()));
398
+
399
+ $ promise = $ this ->client ->containerAttach ('123 ' , true , false );
400
+
401
+ $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
402
+ }
403
+
404
+ public function testContainerAttachReturnsPendingPromiseWhenInspectingContainerResolvesWithTtyAndContainerAttachIsPending ()
405
+ {
406
+ $ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
407
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '{"Config":{"Tty":true}} ' )));
408
+ $ this ->browser ->expects ($ this ->once ())->method ('post ' )->with ('/containers/123/attach?logs=1&stdout=1&stderr=1 ' )->willReturn (new \React \Promise \Promise (function () { }));
409
+
410
+ $ this ->parser ->expects ($ this ->once ())->method ('expectJson ' )->willReturn (array ('Config ' => array ('Tty ' => true )));
411
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('bufferedStream ' )->with ($ this ->isInstanceOf ('React\Stream\ReadableStreamInterface ' ))->willReturn (new \React \Promise \Promise (function () { }));
412
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('parsePlainStream ' )->willReturn ($ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ());
413
+ $ this ->streamingParser ->expects ($ this ->never ())->method ('demultiplexStream ' );
414
+
415
+ $ promise = $ this ->client ->containerAttach ('123 ' , true , false );
416
+
417
+ $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
418
+ }
419
+
420
+ public function testContainerAttachReturnsPendingPromiseWhenInspectingContainerResolvesWithoutTtyAndContainerAttachRequestIsPending ()
421
+ {
422
+ $ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
423
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '{"Config":{"Tty":false}} ' )));
424
+ $ this ->browser ->expects ($ this ->once ())->method ('post ' )->with ('/containers/123/attach?logs=1&stdout=1&stderr=1 ' )->willReturn (new \React \Promise \Promise (function () { }));
425
+
426
+ $ this ->parser ->expects ($ this ->once ())->method ('expectJson ' )->willReturn (array ('Config ' => array ('Tty ' => false )));
427
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('bufferedStream ' )->with ($ this ->isInstanceOf ('React\Stream\ReadableStreamInterface ' ))->willReturn (new \React \Promise \Promise (function () { }));
428
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('parsePlainStream ' )->willReturn ($ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ());
429
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('demultiplexStream ' )->willReturn ($ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ());
430
+
431
+ $ promise = $ this ->client ->containerAttach ('123 ' , true , false );
432
+
433
+ $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
434
+ }
435
+
436
+ public function testContainerAttachResolvesWhenInspectingContainerResolvesWithTtyAndContainerAttachResolvesAndContainerAttachRequestResolves ()
437
+ {
438
+ $ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
439
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '{"Config":{"Tty":true}} ' )));
440
+ $ this ->browser ->expects ($ this ->once ())->method ('post ' )->with ('/containers/123/attach?logs=1&stdout=1&stderr=1 ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '' )));
441
+
442
+ $ this ->parser ->expects ($ this ->once ())->method ('expectJson ' )->willReturn (array ('Config ' => array ('Tty ' => true )));
443
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('bufferedStream ' )->with ($ this ->isInstanceOf ('React\Stream\ReadableStreamInterface ' ))->willReturn (\React \Promise \resolve ('output ' ));
444
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('parsePlainStream ' )->willReturn ($ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ());
445
+ $ this ->streamingParser ->expects ($ this ->never ())->method ('demultiplexStream ' );
446
+
447
+ $ promise = $ this ->client ->containerAttach ('123 ' , true , false );
448
+
449
+ $ promise ->then ($ this ->expectCallableOnceWith ('output ' ), $ this ->expectCallableNever ());
450
+ }
451
+
452
+ public function testContainerAttachStreamReturnStreamWhenInspectingContainerResolvesWithTtyAndContainerAttachRequestResolves ()
453
+ {
454
+ $ this ->browser ->expects ($ this ->once ())->method ('withOptions ' )->willReturnSelf ();
455
+ $ this ->browser ->expects ($ this ->once ())->method ('get ' )->with ('/containers/123/json ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '{"Config":{"Tty":true}} ' )));
456
+ $ this ->browser ->expects ($ this ->once ())->method ('post ' )->with ('/containers/123/attach?logs=1&stream=1&stdout=1&stderr=1 ' )->willReturn (\React \Promise \resolve (new Response (200 , array (), '' )));
457
+
458
+ $ response = new ThroughStream ();
459
+ $ this ->parser ->expects ($ this ->once ())->method ('expectJson ' )->willReturn (array ('Config ' => array ('Tty ' => true )));
460
+ $ this ->streamingParser ->expects ($ this ->once ())->method ('parsePlainStream ' )->willReturn ($ response );
461
+ $ this ->streamingParser ->expects ($ this ->never ())->method ('demultiplexStream ' );
462
+
463
+ $ stream = $ this ->client ->containerAttachStream ('123 ' , true , true );
464
+
465
+ $ stream ->on ('data ' , $ this ->expectCallableOnceWith ('output ' ));
466
+ $ response ->write ('output ' );
467
+ }
468
+
382
469
public function testContainerRemove ()
383
470
{
384
471
$ this ->expectRequestFlow ('delete ' , '/containers/123 ' , $ this ->createResponse (), 'expectEmpty ' );
0 commit comments