@@ -435,7 +435,7 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
435435 'Image ' => 'busybox ' ,
436436 'Cmd ' => array ('echo ' , 'test ' )
437437 );
438- $ networkName = uniqid ('reactphp-docker ' );
438+ $ networkName = uniqid ('reactphp-docker ' , true );
439439
440440 $ promise = $ this ->client ->containerCreate ($ containerConfig );
441441 $ container = Block \await ($ promise , Loop::get ());
@@ -473,9 +473,53 @@ public function testCreateConnectDisconnectAndRemoveNetwork()
473473 $ ret = Block \await ($ promise , Loop::get ());
474474
475475 // 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 );
477477 $ this ->assertEquals ('create ' , $ ret [0 ]['Action ' ]);
478478 $ this ->assertEquals ('disconnect ' , $ ret [1 ]['Action ' ]);
479479 $ this ->assertEquals ('destroy ' , $ ret [2 ]['Action ' ]);
480480 }
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+ }
481525}
0 commit comments