22
33namespace Clue \Tests \React \Ami ;
44
5- use Clue \React \Ami \Factory ;
6- use Clue \React \Ami \Client ;
75use Clue \React \Ami \ActionSender ;
8- use Clue \React \Block ;
6+ use Clue \React \Ami \Client ;
7+ use Clue \React \Ami \Factory ;
8+ use Clue \React \Ami \Protocol \Response ;
9+ use React \EventLoop \Loop ;
910use React \Promise \PromiseInterface ;
1011
1112class FunctionalTest extends TestCase
@@ -19,7 +20,6 @@ class FunctionalTest extends TestCase
1920 public static function setUpLoopBeforeClass ()
2021 {
2122 self ::$ address = getenv ('LOGIN ' );
22- self ::$ loop = \React \EventLoop \Factory::create ();
2323 }
2424
2525 /**
@@ -34,10 +34,10 @@ public function setUpSkipTest()
3434
3535 public function testConnection ()
3636 {
37- $ factory = new Factory (self :: $ loop );
37+ $ factory = new Factory ();
3838
39- $ client = $ this -> waitFor ($ factory ->createClient (self ::$ address ));
40- /* @var $client Client */
39+ $ client = \ React \ Async \await ($ factory ->createClient (self ::$ address ));
40+ assert ( $ client instanceof Client);
4141
4242 $ this ->assertFalse ($ client ->isBusy ());
4343
@@ -52,7 +52,7 @@ public function testPing(Client $client)
5252 {
5353 $ sender = new ActionSender ($ client );
5454
55- $ pong = $ this -> waitFor ($ sender ->ping ());
55+ $ pong = \ React \ Async \await ($ sender ->ping ());
5656
5757 $ this ->assertInstanceOf ('Clue\React\Ami\Protocol\Response ' , $ pong );
5858 }
@@ -64,7 +64,7 @@ public function testPing(Client $client)
6464 public function testInvalidCommandGetsRejected (Client $ client )
6565 {
6666 $ this ->setExpectedException ('Exception ' );
67- $ this -> waitFor ($ client ->request ($ client ->createAction ('Invalid ' )));
67+ \ React \ Async \await ($ client ->request ($ client ->createAction ('Invalid ' )));
6868 }
6969
7070 /**
@@ -75,15 +75,14 @@ public function testActionSenderLogoffDisconnects(Client $client)
7575 {
7676 $ sender = new ActionSender ($ client );
7777
78- $ ret = $ this ->waitFor ($ sender ->logoff ());
79-
80- $ this ->assertInstanceOf ('Clue\React\Ami\Protocol\Response ' , $ ret );
78+ $ ret = \React \Async \await ($ sender ->logoff ());
79+ assert ($ ret instanceof Response);
8180
8281 $ this ->assertFalse ($ client ->isBusy ());
8382
8483 //$client->on('close', $this->expectCallableOnce());
8584
86- self :: $ loop -> run ();
85+ Loop:: run ();
8786
8887 return $ client ;
8988 }
@@ -95,11 +94,6 @@ public function testActionSenderLogoffDisconnects(Client $client)
9594 public function testSendRejectedAfterClose (Client $ client )
9695 {
9796 $ this ->setExpectedException ('Exception ' );
98- $ this ->waitFor ($ client ->request ($ client ->createAction ('Ping ' )));
99- }
100-
101- private function waitFor (PromiseInterface $ promise )
102- {
103- return Block \await ($ promise , self ::$ loop , 5.0 );
97+ \React \Async \await ($ client ->request ($ client ->createAction ('Ping ' )));
10498 }
10599}
0 commit comments