11<?php
22
3+ use Clue \React \Block ;
4+ use Clue \React \Zenity \Zen \BaseZen ;
35use React \EventLoop \Factory ;
46use React \ChildProcess \Process ;
5- use Clue \ React \ Zenity \ Zen \ BaseZen ;
7+
68class FunctionalBaseZenTest extends TestCase
79{
810 public function setUp ()
@@ -18,9 +20,9 @@ public function testZenResolvesWithProcessOutput()
1820 $ zen = new BaseZen ();
1921 $ zen ->go ($ process );
2022
21- $ this -> loop -> run ( );
23+ $ result = Block \await ( $ zen -> promise (), $ this -> loop , 1.0 );
2224
23- $ zen -> promise ()-> then ( $ this ->expectCallableOnceWith ('okay ' ) );
25+ $ this ->assertEquals ('okay ' , $ result );
2426 }
2527
2628 public function testZenResolvesWithTrueWhenProcessHasNoOutput ()
@@ -31,9 +33,9 @@ public function testZenResolvesWithTrueWhenProcessHasNoOutput()
3133 $ zen = new BaseZen ();
3234 $ zen ->go ($ process );
3335
34- $ this -> loop -> run ( );
36+ $ result = Block \await ( $ zen -> promise (), $ this -> loop , 1.0 );
3537
36- $ zen -> promise ()-> then ( $ this ->expectCallableOnceWith ( true ) );
38+ $ this ->assertTrue ( $ result );
3739 }
3840
3941 public function testZenRejectsWhenProcessReturnsError ()
@@ -44,9 +46,7 @@ public function testZenRejectsWhenProcessReturnsError()
4446 $ zen = new BaseZen ();
4547 $ zen ->go ($ process );
4648
47- $ this ->loop ->run ();
48-
49- $ zen ->promise ()->then (null , $ this ->expectCallableOnceWith (1 ));
49+ Block \await ($ zen ->promise ()->then (null , $ this ->expectCallableOnceWith (1 )), $ this ->loop , 1.0 );
5050 }
5151
5252 public function testClosingZenResolvesWithOutputSoFar ()
@@ -61,9 +61,9 @@ public function testClosingZenResolvesWithOutputSoFar()
6161 $ zen ->close ();
6262 });
6363
64- $ this -> loop -> run ( );
64+ $ result = Block \await ( $ zen -> promise (), $ this -> loop , 1.0 );
6565
66- $ zen -> promise ()-> then ( $ this ->expectCallableOnceWith ('okay ' ) );
66+ $ this ->assertEquals ('okay ' , $ result );
6767 }
6868
6969 public function testTerminatingProcessReturnsError ()
@@ -76,10 +76,9 @@ public function testTerminatingProcessReturnsError()
7676
7777 $ this ->loop ->addTimer (0.1 , function () use ($ process ) {
7878 $ process ->terminate (SIGKILL );
79+ $ process ->stdin ->end ();
7980 });
8081
81- $ this ->loop ->run ();
82-
83- $ zen ->promise ()->then (null , $ this ->expectCallableOnce ());
82+ Block \await ($ zen ->promise ()->then (null , $ this ->expectCallableOnce ()), $ this ->loop , 1.0 );
8483 }
8584}
0 commit comments