@@ -435,7 +435,7 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
435
435
'Image ' => 'busybox ' ,
436
436
'Cmd ' => array ('echo ' , 'test ' )
437
437
);
438
- $ networkName = uniqid ('reactphp-docker ' );
438
+ $ networkName = uniqid ('reactphp-docker ' , true );
439
439
440
440
$ promise = $ this ->client ->containerCreate ($ containerConfig );
441
441
$ container = Block \await ($ promise , Loop::get ());
@@ -473,9 +473,53 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
473
473
$ ret = Block \await ($ promise , Loop::get ());
474
474
475
475
// expects "create", "disconnect", "destroy" events ("connect" will be skipped because we don't start the container)
476
- $ this ->assertEquals (3 , count ( $ ret) );
476
+ $ this ->assertCount (3 , $ ret );
477
477
$ this ->assertEquals ('create ' , $ ret [0 ]['Action ' ]);
478
478
$ this ->assertEquals ('disconnect ' , $ ret [1 ]['Action ' ]);
479
479
$ this ->assertEquals ('destroy ' , $ ret [2 ]['Action ' ]);
480
480
}
481
+
482
+ /**
483
+ * @depends testImageInspectCheckIfBusyboxExists
484
+ */
485
+ public function testCreateAndCommitContainer ()
486
+ {
487
+ $ config = array (
488
+ 'Image ' => 'busybox ' ,
489
+ 'Cmd ' => array ('echo ' , 'test ' )
490
+ );
491
+
492
+ $ promise = $ this ->client ->containerCreate ($ config );
493
+ $ container = Block \await ($ promise , Loop::get ());
494
+
495
+ $ this ->assertNotNull ($ container ['Id ' ]);
496
+ $ this ->assertEmpty ($ container ['Warnings ' ]);
497
+
498
+ $ promise = $ this ->client ->containerCommit ($ container ['Id ' ]);
499
+ $ image = Block \await ($ promise , Loop::get ());
500
+
501
+ $ this ->assertNotNull ($ image ['Id ' ]);
502
+ $ this ->assertArrayNotHasKey ('message ' , $ image );
503
+
504
+ $ promise = $ this ->client ->containerRemove ($ container ['Id ' ], false , true );
505
+ $ ret = Block \await ($ promise , Loop::get ());
506
+
507
+ $ this ->assertEquals ('' , $ ret );
508
+
509
+ $ config = array (
510
+ 'Image ' => $ image ['Id ' ],
511
+ 'Cmd ' => array ('echo ' , 'test ' )
512
+ );
513
+
514
+ $ promise = $ this ->client ->containerCreate ($ config );
515
+ $ container = Block \await ($ promise , Loop::get ());
516
+
517
+ $ this ->assertNotNull ($ container ['Id ' ]);
518
+ $ this ->assertEmpty ($ container ['Warnings ' ]);
519
+
520
+ $ promise = $ this ->client ->containerRemove ($ container ['Id ' ], false , true );
521
+ $ ret = Block \await ($ promise , Loop::get ());
522
+
523
+ $ this ->assertEquals ('' , $ ret );
524
+ }
481
525
}
0 commit comments