@@ -196,25 +196,43 @@ public function testCreateClientWithAuthUrlReceivesSessionInit()
196196 $ factory = new Factory ();
197197
198198 $ url = rawurlencode (self ::$ username ) . ': ' . rawurlencode (self ::$ password ) . '@ ' . self ::$ host ;
199- $ promise = $ factory ->createClient ($ url );
200- $ client = Block \await ($ promise , Loop::get (), 10.0 );
201199
202- $ message = $ this ->awaitMessage ($ client );
203- $ this ->assertEquals ('SessionInit ' , $ message ->MsgType );
200+ $ promise = $ factory ->createClient ($ url )->then (function (Client $ client ) {
201+ return new Promise (function ($ resolve , $ reject ) use ($ client ) {
202+ $ client ->once ('data ' , function ($ message ) use ($ client , $ resolve ) {
203+ $ client ->close ();
204+ $ resolve ($ message );
205+ });
204206
205- $ client ->close ();
207+ $ client ->once ('error ' , $ reject );
208+ $ client ->once ('close ' , $ reject );
209+ });
210+ });
211+
212+ $ message = Block \await ($ promise , Loop::get (), 10.0 );
213+ $ this ->assertEquals ('SessionInit ' , $ message ->MsgType );
206214 }
207215
208216 public function testRequestBacklogReceivesBacklog ()
209217 {
210218 $ factory = new Factory ();
211219
212220 $ url = rawurlencode (self ::$ username ) . ': ' . rawurlencode (self ::$ password ) . '@ ' . self ::$ host ;
213- $ promise = $ factory ->createClient ($ url );
214- $ client = Block \await ($ promise , Loop::get (), 10.0 );
215- /* @var $client Client */
216221
217- $ message = $ this ->awaitMessage ($ client );
222+ $ promise = $ factory ->createClient ($ url )->then (function (Client $ client ) {
223+ return new Promise (function ($ resolve , $ reject ) use ($ client ) {
224+ $ client ->once ('data ' , function ($ message ) use ($ client , $ resolve ) {
225+ $ resolve (array ($ client , $ message ));
226+ });
227+
228+ $ client ->once ('error ' , $ reject );
229+ $ client ->once ('close ' , $ reject );
230+ });
231+ });
232+
233+ list ($ client , $ message ) = Block \await ($ promise , Loop::get (), 10.0 );
234+ assert ($ client instanceof Client);
235+
218236 $ this ->assertEquals ('SessionInit ' , $ message ->MsgType );
219237
220238 // try to pick first buffer
0 commit comments