22
33namespace React \Tests \Socket ;
44
5- use Clue \React \Block ;
6- use Evenement \EventEmitterInterface ;
75use React \Promise \Promise ;
86use React \Socket \ConnectionInterface ;
97use React \Socket \SecureConnector ;
@@ -39,7 +37,7 @@ public function testClientCanConnectToServer()
3937 $ promise = $ connector ->connect ($ server ->getAddress ());
4038
4139 /* @var ConnectionInterface $client */
42- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
40+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
4341
4442 $ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ client );
4543 $ this ->assertEquals ($ server ->getAddress (), $ client ->getRemoteAddress ());
@@ -68,7 +66,7 @@ public function testClientUsesTls13ByDefaultWhenSupportedByOpenSSL()
6866 $ promise = $ connector ->connect ($ server ->getAddress ());
6967
7068 /* @var ConnectionInterface $client */
71- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
69+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
7270
7371 $ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
7472 $ this ->assertTrue (isset ($ client ->stream ));
@@ -107,7 +105,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByClien
107105 $ promise = $ connector ->connect ($ server ->getAddress ());
108106
109107 /* @var ConnectionInterface $client */
110- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
108+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
111109
112110 $ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
113111 $ this ->assertTrue (isset ($ client ->stream ));
@@ -138,7 +136,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByServe
138136 $ promise = $ connector ->connect ($ server ->getAddress ());
139137
140138 /* @var ConnectionInterface $client */
141- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
139+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
142140
143141 $ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
144142 $ this ->assertTrue (isset ($ client ->stream ));
@@ -170,7 +168,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien
170168
171169 /* @var ConnectionInterface $client */
172170 try {
173- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
171+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
174172 } catch (\RuntimeException $ e ) {
175173 // legacy TLS 1.0 would be considered insecure by today's standards, so skip test if connection fails
176174 // OpenSSL error messages are version/platform specific
@@ -212,7 +210,7 @@ public function testServerEmitsConnectionForClientConnection()
212210
213211 // await both client and server side end of connection
214212 /* @var ConnectionInterface[] $both */
215- $ both = Block \awaitAll ( array ($ peer , $ client ), null , self ::TIMEOUT );
213+ $ both = \ React \ Async \await ( \ React \ Promise \ Timer \timeout ( \ React \ Promise \all ( array ($ peer , $ client )), self ::TIMEOUT ) );
216214
217215 // both ends of the connection are represented by different instances of ConnectionInterface
218216 $ this ->assertCount (2 , $ both );
@@ -252,7 +250,7 @@ public function testClientEmitsDataEventOnceForDataWrittenFromServer()
252250 }, $ reject );
253251 });
254252
255- $ data = Block \ await ($ promise , null , self ::TIMEOUT );
253+ $ data = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
256254
257255 $ this ->assertEquals ('foo ' , $ data );
258256
@@ -293,7 +291,7 @@ public function testWritesDataInMultipleChunksToConnection()
293291 }, $ reject );
294292 });
295293
296- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
294+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
297295
298296 $ this ->assertEquals (400000 , $ received );
299297
@@ -334,7 +332,7 @@ public function testWritesMoreDataInMultipleChunksToConnection()
334332 }, $ reject );
335333 });
336334
337- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
335+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
338336
339337 $ this ->assertEquals (2000000 , $ received );
340338
@@ -367,7 +365,7 @@ public function testEmitsDataFromConnection()
367365 $ connection ->write ('foo ' );
368366 });
369367
370- $ data = Block \ await ($ promise , null , self ::TIMEOUT );
368+ $ data = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
371369
372370 $ this ->assertEquals ('foo ' , $ data );
373371
@@ -407,7 +405,7 @@ public function testEmitsDataInMultipleChunksFromConnection()
407405 $ connection ->write (str_repeat ('* ' , 400000 ));
408406 });
409407
410- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
408+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
411409
412410 $ this ->assertEquals (400000 , $ received );
413411
@@ -449,7 +447,7 @@ public function testPipesDataBackInMultipleChunksFromConnection()
449447 }, $ reject );
450448 });
451449
452- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
450+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
453451
454452 $ this ->assertEquals (400000 , $ received );
455453
@@ -479,7 +477,7 @@ public function testEmitsConnectionForNewTlsv11Connection()
479477 ));
480478 $ promise = $ connector ->connect ($ server ->getAddress ());
481479
482- Block \ await ($ promise , null , self ::TIMEOUT );
480+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
483481
484482 $ server ->close ();
485483 $ promise ->then (function (ConnectionInterface $ connection ) {
@@ -510,7 +508,7 @@ public function testEmitsErrorForClientWithTlsVersionMismatch()
510508 $ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
511509
512510 try {
513- Block \ await ($ promise , null , self ::TIMEOUT );
511+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
514512 } catch (\Exception $ e ) {
515513 $ server ->close ();
516514
@@ -536,7 +534,7 @@ public function testServerEmitsConnectionForNewConnectionWithEncryptedCertificat
536534 ));
537535 $ connector ->connect ($ server ->getAddress ());
538536
539- $ connection = Block \ await ($ peer , null , self ::TIMEOUT );
537+ $ connection = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ peer , self ::TIMEOUT ) );
540538
541539 $ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
542540
@@ -559,7 +557,7 @@ public function testClientRejectsWithErrorForServerWithInvalidCertificate()
559557 $ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
560558
561559 try {
562- Block \ await ($ promise , null , self ::TIMEOUT );
560+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
563561 } catch (\Exception $ e ) {
564562 $ server ->close ();
565563
@@ -589,7 +587,7 @@ public function testServerEmitsErrorForClientWithInvalidCertificate()
589587 $ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
590588
591589 try {
592- Block \ await ($ peer , null , self ::TIMEOUT );
590+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ peer , self ::TIMEOUT ) );
593591 } catch (\Exception $ e ) {
594592 $ server ->close ();
595593
@@ -618,7 +616,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateMissingPassphrase
618616 $ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
619617
620618 try {
621- Block \ await ($ promise , null , self ::TIMEOUT );
619+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
622620 } catch (\Exception $ e ) {
623621 $ server ->close ();
624622
@@ -648,7 +646,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateWithInvalidPassph
648646 $ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
649647
650648 try {
651- Block \ await ($ promise , null , self ::TIMEOUT );
649+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
652650 } catch (\Exception $ e ) {
653651 $ server ->close ();
654652
@@ -671,7 +669,7 @@ public function testEmitsErrorForConnectionWithPeerVerification()
671669 $ promise = $ connector ->connect ($ server ->getAddress ());
672670 $ promise ->then (null , $ this ->expectCallableOnce ());
673671
674- Block \ await ($ errorEvent , null , self ::TIMEOUT );
672+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
675673
676674 $ server ->close ();
677675 }
@@ -696,7 +694,7 @@ public function testEmitsErrorIfConnectionIsCancelled()
696694 $ promise ->cancel ();
697695 $ promise ->then (null , $ this ->expectCallableOnce ());
698696
699- Block \ await ($ errorEvent , null , self ::TIMEOUT );
697+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
700698
701699 $ server ->close ();
702700 }
@@ -717,7 +715,7 @@ public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()
717715 $ stream ->close ();
718716 });
719717
720- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
718+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
721719
722720 // Connection from tcp://127.0.0.1:39528 failed during TLS handshake: Connection lost during TLS handshake (ECONNRESET)
723721 $ this ->assertInstanceOf ('RuntimeException ' , $ error );
@@ -745,7 +743,7 @@ public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()
745743 $ stream ->end ("\x1e" );
746744 });
747745
748- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
746+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
749747
750748 // Connection from tcp://127.0.0.1:39528 failed during TLS handshake: Connection lost during TLS handshake (ECONNRESET)
751749 $ this ->assertInstanceOf ('RuntimeException ' , $ error );
@@ -769,7 +767,7 @@ public function testEmitsNothingIfPlaintextConnectionIsIdle()
769767 $ connector = new TcpConnector ();
770768 $ promise = $ connector ->connect (str_replace ('tls:// ' , '' , $ server ->getAddress ()));
771769
772- $ connection = Block \ await ($ promise , null , self ::TIMEOUT );
770+ $ connection = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
773771 $ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
774772
775773 $ server ->close ();
@@ -794,7 +792,7 @@ public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()
794792 $ stream ->write ("GET / HTTP/1.0 \r\n\r\n" );
795793 });
796794
797- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
795+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
798796
799797 $ this ->assertInstanceOf ('RuntimeException ' , $ error );
800798
@@ -823,7 +821,7 @@ public function testEmitsErrorIfConnectionIsUnknownProtocolInsteadOfSecureHandsh
823821 $ stream ->write ("Hello world! \n" );
824822 });
825823
826- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
824+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
827825
828826 $ this ->assertInstanceOf ('RuntimeException ' , $ error );
829827
0 commit comments