@@ -72,6 +72,103 @@ public function testCreateStartAndRemoveContainer()
7272 $ this ->assertEquals ('destroy ' , $ ret [3 ]['status ' ]);
7373 }
7474
75+ public function testStartRunning ()
76+ {
77+ $ config = array (
78+ 'Image ' => 'busybox ' ,
79+ 'Tty ' => true ,
80+ 'Cmd ' => array ('sleep ' , '10 ' )
81+ );
82+
83+ $ promise = $ this ->client ->containerCreate ($ config );
84+ $ container = Block \await ($ promise , $ this ->loop );
85+
86+ $ this ->assertNotNull ($ container ['Id ' ]);
87+ $ this ->assertNull ($ container ['Warnings ' ]);
88+
89+ $ start = microtime (true );
90+
91+ $ promise = $ this ->client ->containerStart ($ container ['Id ' ]);
92+ $ ret = Block \await ($ promise , $ this ->loop );
93+
94+ $ this ->assertEquals ('' , $ ret );
95+
96+ return $ container ['Id ' ];
97+ }
98+
99+ /**
100+ * @depends testStartRunning
101+ * @param string $container
102+ * @return string
103+ */
104+ public function testExecCreateWhileRunning ($ container )
105+ {
106+ $ promise = $ this ->client ->execCreate ($ container , array (
107+ 'Cmd ' => array ('echo ' , '-n ' , 'hello ' , 'world ' ),
108+ 'AttachStdout ' => true ,
109+ 'AttachStderr ' => true ,
110+ 'Tty ' => true
111+ ));
112+ $ exec = Block \await ($ promise , $ this ->loop );
113+
114+ $ this ->assertTrue (is_array ($ exec ));
115+ $ this ->assertTrue (is_string ($ exec ['Id ' ]));
116+
117+ return $ exec ['Id ' ];
118+ }
119+
120+ /**
121+ * @depends testExecCreateWhileRunning
122+ * @param string $exec
123+ */
124+ public function testExecInspectBeforeRunning ($ exec )
125+ {
126+ $ promise = $ this ->client ->execInspect ($ exec );
127+ $ info = Block \await ($ promise , $ this ->loop );
128+
129+ $ this ->assertTrue (is_array ($ info ));
130+ $ this ->assertFalse ($ info ['Running ' ]);
131+ $ this ->assertEquals (null , $ info ['ExitCode ' ]);
132+ }
133+
134+ /**
135+ * @depends testExecCreateWhileRunning
136+ * @param string $exec
137+ */
138+ public function testExecStartWhileRunning ($ exec )
139+ {
140+ $ promise = $ this ->client ->execStart ($ exec , array ('Tty ' => true ));
141+ $ output = Block \await ($ promise , $ this ->loop );
142+
143+ $ this ->assertEquals ('hello world ' , $ output );
144+ }
145+
146+ /**
147+ * @depends testExecCreateWhileRunning
148+ * @param string $exec
149+ */
150+ public function testExecInspectAfterRunning ($ exec )
151+ {
152+ $ promise = $ this ->client ->execInspect ($ exec );
153+ $ info = Block \await ($ promise , $ this ->loop );
154+
155+ $ this ->assertTrue (is_array ($ info ));
156+ $ this ->assertFalse ($ info ['Running ' ]);
157+ $ this ->assertEquals (0 , $ info ['ExitCode ' ]);
158+ }
159+
160+ /**
161+ * @depends testStartRunning
162+ * @param string $container
163+ */
164+ public function testRemoveRunning ($ container )
165+ {
166+ $ promise = $ this ->client ->containerRemove ($ container , true , true );
167+ $ ret = Block \await ($ promise , $ this ->loop );
168+
169+ $ this ->assertEquals ('' , $ ret );
170+ }
171+
75172 /**
76173 * @expectedException RuntimeException
77174 */
0 commit comments