@@ -67,7 +67,7 @@ public function testGetTermSignalWhenRunning($process)
6767
6868 public function testProcessWithDefaultCwdAndEnv ()
6969 {
70- $ cmd = PHP_BINARY . ' -r ' . escapeshellarg ('echo getcwd(), PHP_EOL, count($_SERVER), PHP_EOL; ' );
70+ $ cmd = $ this -> cmd ('echo getcwd(), PHP_EOL, count($_SERVER), PHP_EOL; ' );
7171
7272 $ loop = $ this ->createLoop ();
7373 $ process = new Process ($ cmd );
@@ -95,7 +95,7 @@ public function testProcessWithDefaultCwdAndEnv()
9595
9696 public function testProcessWithCwd ()
9797 {
98- $ cmd = PHP_BINARY . ' -r ' . escapeshellarg ('echo getcwd(), PHP_EOL; ' );
98+ $ cmd = $ this -> cmd ('echo getcwd(), PHP_EOL; ' );
9999
100100 $ loop = $ this ->createLoop ();
101101 $ process = new Process ($ cmd , '/ ' );
@@ -120,7 +120,7 @@ public function testProcessWithEnv()
120120 $ this ->markTestSkipped ('Cannot execute PHP processes with custom environments on Travis CI. ' );
121121 }
122122
123- $ cmd = PHP_BINARY . ' -r ' . escapeshellarg ('echo getenv("foo"), PHP_EOL; ' );
123+ $ cmd = $ this -> cmd ('echo getenv("foo"), PHP_EOL; ' );
124124
125125 $ loop = $ this ->createLoop ();
126126 $ process = new Process ($ cmd , null , array ('foo ' => 'bar ' ));
@@ -267,21 +267,22 @@ public function testTerminateWithStopAndContinueSignalsUsingEventLoop()
267267 $ termSignal = func_get_arg (1 );
268268 });
269269
270- $ loop ->addTimer (0.001 , function (Timer $ timer ) use ($ process ) {
270+ $ that = $ this ;
271+ $ loop ->addTimer (0.001 , function (Timer $ timer ) use ($ process , $ that ) {
271272 $ process ->start ($ timer ->getLoop ());
272273 $ process ->terminate (SIGSTOP );
273274
274- $ this ->assertSoon (function () use ($ process ) {
275- $ this ->assertTrue ($ process ->isStopped ());
276- $ this ->assertTrue ($ process ->isRunning ());
277- $ this ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
275+ $ that ->assertSoon (function () use ($ process, $ that ) {
276+ $ that ->assertTrue ($ process ->isStopped ());
277+ $ that ->assertTrue ($ process ->isRunning ());
278+ $ that ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
278279 });
279280
280281 $ process ->terminate (SIGCONT );
281282
282- $ this ->assertSoon (function () use ($ process ) {
283- $ this ->assertFalse ($ process ->isStopped ());
284- $ this ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
283+ $ that ->assertSoon (function () use ($ process, $ that ) {
284+ $ that ->assertFalse ($ process ->isStopped ());
285+ $ that ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
285286 });
286287 });
287288
@@ -325,4 +326,9 @@ public function assertSoon(\Closure $callback, $timeout = 20000, $interval = 200
325326 usleep ($ interval );
326327 }
327328 }
329+
330+ private function cmd ($ code )
331+ {
332+ return (defined ('PHP_BINARY ' ) ? PHP_BINARY : 'php ' ) . ' -r ' . escapeshellarg ($ code );
333+ }
328334}
0 commit comments