22
33namespace React \Tests \ChildProcess ;
44
5- use React \ChildProcess \Process ;
6- use React \EventLoop \Timer \Timer ;
75use PHPUnit \Framework \ExpectationFailedException ;
86use PHPUnit \Framework \TestCase ;
7+ use React \ChildProcess \Process ;
98use SebastianBergmann \Environment \Runtime ;
109
1110abstract class AbstractProcessTest extends TestCase
@@ -156,8 +155,8 @@ public function testProcessWithDefaultCwdAndEnv()
156155
157156 $ output = '' ;
158157
159- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process , &$ output ) {
160- $ process ->start ($ timer -> getLoop () );
158+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop , &$ output ) {
159+ $ process ->start ($ loop );
161160 $ process ->stdout ->on ('data ' , function () use (&$ output ) {
162161 $ output .= func_get_arg (0 );
163162 });
@@ -184,8 +183,8 @@ public function testProcessWithCwd()
184183
185184 $ output = '' ;
186185
187- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process , &$ output ) {
188- $ process ->start ($ timer -> getLoop () );
186+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop , &$ output ) {
187+ $ process ->start ($ loop );
189188 $ process ->stdout ->on ('data ' , function () use (&$ output ) {
190189 $ output .= func_get_arg (0 );
191190 });
@@ -209,8 +208,8 @@ public function testProcessWithEnv()
209208
210209 $ output = '' ;
211210
212- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process , &$ output ) {
213- $ process ->start ($ timer -> getLoop () );
211+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop , &$ output ) {
212+ $ process ->start ($ loop );
214213 $ process ->stdout ->on ('data ' , function () use (&$ output ) {
215214 $ output .= func_get_arg (0 );
216215 });
@@ -236,8 +235,8 @@ public function testStartAndAllowProcessToExitSuccessfullyUsingEventLoop()
236235 $ termSignal = func_get_arg (1 );
237236 });
238237
239- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process ) {
240- $ process ->start ($ timer -> getLoop () );
238+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop ) {
239+ $ process ->start ($ loop );
241240 });
242241
243242 $ loop ->run ();
@@ -261,8 +260,8 @@ public function testStartInvalidProcess()
261260
262261 $ output = '' ;
263262
264- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process , &$ output ) {
265- $ process ->start ($ timer -> getLoop () );
263+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop , &$ output ) {
264+ $ process ->start ($ loop );
266265 $ process ->stderr ->on ('data ' , function () use (&$ output ) {
267266 $ output .= func_get_arg (0 );
268267 });
@@ -338,8 +337,8 @@ public function testTerminateWithDefaultTermSignalUsingEventLoop()
338337 $ termSignal = func_get_arg (1 );
339338 });
340339
341- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process ) {
342- $ process ->start ($ timer -> getLoop () );
340+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop ) {
341+ $ process ->start ($ loop );
343342 $ process ->terminate ();
344343 });
345344
@@ -379,19 +378,19 @@ public function testTerminateWithStopAndContinueSignalsUsingEventLoop()
379378 });
380379
381380 $ that = $ this ;
382- $ loop ->addTimer (0.001 , function ( Timer $ timer ) use ($ process , $ that ) {
383- $ process ->start ($ timer -> getLoop () );
381+ $ loop ->addTimer (0.001 , function ( ) use ($ process, $ loop , $ that ) {
382+ $ process ->start ($ loop );
384383 $ process ->terminate (SIGSTOP );
385384
386- $ that ->assertSoon (function () use ($ process , $ that ) {
385+ $ that ->assertSoon (function () use ($ process , $ that ) {
387386 $ that ->assertTrue ($ process ->isStopped ());
388387 $ that ->assertTrue ($ process ->isRunning ());
389388 $ that ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
390389 });
391390
392391 $ process ->terminate (SIGCONT );
393392
394- $ that ->assertSoon (function () use ($ process , $ that ) {
393+ $ that ->assertSoon (function () use ($ process , $ that ) {
395394 $ that ->assertFalse ($ process ->isStopped ());
396395 $ that ->assertEquals (SIGSTOP , $ process ->getStopSignal ());
397396 });
@@ -444,7 +443,12 @@ function ($output) use (&$stdErr) {
444443 }
445444 );
446445
447- $ loop ->tick ();
446+ // tick loop once
447+ $ loop ->addTimer (0 , function () use ($ loop ) {
448+ $ loop ->stop ();
449+ });
450+ $ loop ->run ();
451+
448452 sleep (1 ); // comment this line out and it works fine
449453
450454 $ loop ->run ();
0 commit comments