@@ -104,12 +104,7 @@ public function testStartRunning()
104104 */
105105 public function testExecCreateWhileRunning ($ container )
106106 {
107- $ promise = $ this ->client ->execCreate ($ container , array (
108- 'Cmd ' => array ('echo ' , '-n ' , 'hello ' , 'world ' ),
109- 'AttachStdout ' => true ,
110- 'AttachStderr ' => true ,
111- 'Tty ' => true
112- ));
107+ $ promise = $ this ->client ->execCreate ($ container , array ('echo ' , '-n ' , 'hello ' , 'world ' ));
113108 $ exec = Block \await ($ promise , $ this ->loop );
114109
115110 $ this ->assertTrue (is_array ($ exec ));
@@ -158,18 +153,67 @@ public function testExecInspectAfterRunning($exec)
158153 $ this ->assertEquals (0 , $ info ['ExitCode ' ]);
159154 }
160155
156+ /**
157+ * @depends testStartRunning
158+ * @param string $container
159+ */
160+ public function testExecStringCommandWithOutputWhileRunning ($ container )
161+ {
162+ $ promise = $ this ->client ->execCreate ($ container , 'echo -n hello world ' );
163+ $ exec = Block \await ($ promise , $ this ->loop );
164+
165+ $ this ->assertTrue (is_array ($ exec ));
166+ $ this ->assertTrue (is_string ($ exec ['Id ' ]));
167+
168+ $ promise = $ this ->client ->execStart ($ exec ['Id ' ], true );
169+ $ output = Block \await ($ promise , $ this ->loop );
170+
171+ $ this ->assertEquals ('hello world ' , $ output );
172+ }
173+
174+ /**
175+ * @depends testStartRunning
176+ * @param string $container
177+ */
178+ public function testExecUserSpecificCommandWithOutputWhileRunning ($ container )
179+ {
180+ $ promise = $ this ->client ->execCreate ($ container , 'whoami ' , true , false , true , true , 'nobody ' );
181+ $ exec = Block \await ($ promise , $ this ->loop );
182+
183+ $ this ->assertTrue (is_array ($ exec ));
184+ $ this ->assertTrue (is_string ($ exec ['Id ' ]));
185+
186+ $ promise = $ this ->client ->execStart ($ exec ['Id ' ], true );
187+ $ output = Block \await ($ promise , $ this ->loop );
188+
189+ $ this ->assertEquals ('nobody ' , rtrim ($ output ));
190+ }
191+
192+ /**
193+ * @depends testStartRunning
194+ * @param string $container
195+ */
196+ public function testExecStringCommandWithStderrOutputWhileRunning ($ container )
197+ {
198+ $ promise = $ this ->client ->execCreate ($ container , 'echo -n hello world >&2 ' , true );
199+ $ exec = Block \await ($ promise , $ this ->loop );
200+
201+ $ this ->assertTrue (is_array ($ exec ));
202+ $ this ->assertTrue (is_string ($ exec ['Id ' ]));
203+
204+ $ promise = $ this ->client ->execStart ($ exec ['Id ' ], true );
205+ $ output = Block \await ($ promise , $ this ->loop );
206+
207+ $ this ->assertEquals ('hello world ' , $ output );
208+ }
209+
161210 /**
162211 * @depends testStartRunning
163212 * @param string $container
164213 */
165214 public function testExecStreamEmptyOutputWhileRunning ($ container )
166215 {
167- $ promise = $ this ->client ->execCreate ($ container , array (
168- 'Cmd ' => array ('true ' ),
169- 'AttachStdout ' => true ,
170- 'AttachStderr ' => true ,
171- 'Tty ' => true
172- ));
216+ $ promise = $ this ->client ->execCreate ($ container , array ('true ' ));
173217 $ exec = Block \await ($ promise , $ this ->loop );
174218
175219 $ this ->assertTrue (is_array ($ exec ));
@@ -189,12 +233,7 @@ public function testExecStreamEmptyOutputWhileRunning($container)
189233 */
190234 public function testExecDetachedWhileRunning ($ container )
191235 {
192- $ promise = $ this ->client ->execCreate ($ container , array (
193- 'Cmd ' => array ('sleep ' , '10 ' ),
194- 'AttachStdout ' => true ,
195- 'AttachStderr ' => true ,
196- 'Tty ' => true
197- ));
236+ $ promise = $ this ->client ->execCreate ($ container , array ('sleep ' , '10 ' ));
198237 $ exec = Block \await ($ promise , $ this ->loop );
199238
200239 $ this ->assertTrue (is_array ($ exec ));
0 commit comments