2
2
3
3
namespace React \Tests \Socket ;
4
4
5
- use Clue \React \Block ;
6
- use Evenement \EventEmitterInterface ;
7
5
use React \Promise \Promise ;
8
6
use React \Socket \ConnectionInterface ;
9
7
use React \Socket \SecureConnector ;
@@ -39,7 +37,7 @@ public function testClientCanConnectToServer()
39
37
$ promise = $ connector ->connect ($ server ->getAddress ());
40
38
41
39
/* @var ConnectionInterface $client */
42
- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
40
+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
43
41
44
42
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ client );
45
43
$ this ->assertEquals ($ server ->getAddress (), $ client ->getRemoteAddress ());
@@ -68,7 +66,7 @@ public function testClientUsesTls13ByDefaultWhenSupportedByOpenSSL()
68
66
$ promise = $ connector ->connect ($ server ->getAddress ());
69
67
70
68
/* @var ConnectionInterface $client */
71
- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
69
+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
72
70
73
71
$ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
74
72
$ this ->assertTrue (isset ($ client ->stream ));
@@ -107,7 +105,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByClien
107
105
$ promise = $ connector ->connect ($ server ->getAddress ());
108
106
109
107
/* @var ConnectionInterface $client */
110
- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
108
+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
111
109
112
110
$ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
113
111
$ this ->assertTrue (isset ($ client ->stream ));
@@ -138,7 +136,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByServe
138
136
$ promise = $ connector ->connect ($ server ->getAddress ());
139
137
140
138
/* @var ConnectionInterface $client */
141
- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
139
+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
142
140
143
141
$ this ->assertInstanceOf ('React\Socket\Connection ' , $ client );
144
142
$ this ->assertTrue (isset ($ client ->stream ));
@@ -170,7 +168,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien
170
168
171
169
/* @var ConnectionInterface $client */
172
170
try {
173
- $ client = Block \ await ($ promise , null , self ::TIMEOUT );
171
+ $ client = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
174
172
} catch (\RuntimeException $ e ) {
175
173
// legacy TLS 1.0 would be considered insecure by today's standards, so skip test if connection fails
176
174
// OpenSSL error messages are version/platform specific
@@ -212,7 +210,7 @@ public function testServerEmitsConnectionForClientConnection()
212
210
213
211
// await both client and server side end of connection
214
212
/* @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 ) );
216
214
217
215
// both ends of the connection are represented by different instances of ConnectionInterface
218
216
$ this ->assertCount (2 , $ both );
@@ -252,7 +250,7 @@ public function testClientEmitsDataEventOnceForDataWrittenFromServer()
252
250
}, $ reject );
253
251
});
254
252
255
- $ data = Block \ await ($ promise , null , self ::TIMEOUT );
253
+ $ data = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
256
254
257
255
$ this ->assertEquals ('foo ' , $ data );
258
256
@@ -293,7 +291,7 @@ public function testWritesDataInMultipleChunksToConnection()
293
291
}, $ reject );
294
292
});
295
293
296
- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
294
+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
297
295
298
296
$ this ->assertEquals (400000 , $ received );
299
297
@@ -334,7 +332,7 @@ public function testWritesMoreDataInMultipleChunksToConnection()
334
332
}, $ reject );
335
333
});
336
334
337
- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
335
+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
338
336
339
337
$ this ->assertEquals (2000000 , $ received );
340
338
@@ -367,7 +365,7 @@ public function testEmitsDataFromConnection()
367
365
$ connection ->write ('foo ' );
368
366
});
369
367
370
- $ data = Block \ await ($ promise , null , self ::TIMEOUT );
368
+ $ data = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
371
369
372
370
$ this ->assertEquals ('foo ' , $ data );
373
371
@@ -407,7 +405,7 @@ public function testEmitsDataInMultipleChunksFromConnection()
407
405
$ connection ->write (str_repeat ('* ' , 400000 ));
408
406
});
409
407
410
- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
408
+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
411
409
412
410
$ this ->assertEquals (400000 , $ received );
413
411
@@ -449,7 +447,7 @@ public function testPipesDataBackInMultipleChunksFromConnection()
449
447
}, $ reject );
450
448
});
451
449
452
- $ received = Block \ await ($ promise , null , self ::TIMEOUT );
450
+ $ received = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
453
451
454
452
$ this ->assertEquals (400000 , $ received );
455
453
@@ -479,7 +477,7 @@ public function testEmitsConnectionForNewTlsv11Connection()
479
477
));
480
478
$ promise = $ connector ->connect ($ server ->getAddress ());
481
479
482
- Block \ await ($ promise , null , self ::TIMEOUT );
480
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
483
481
484
482
$ server ->close ();
485
483
$ promise ->then (function (ConnectionInterface $ connection ) {
@@ -510,7 +508,7 @@ public function testEmitsErrorForClientWithTlsVersionMismatch()
510
508
$ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
511
509
512
510
try {
513
- Block \ await ($ promise , null , self ::TIMEOUT );
511
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
514
512
} catch (\Exception $ e ) {
515
513
$ server ->close ();
516
514
@@ -536,7 +534,7 @@ public function testServerEmitsConnectionForNewConnectionWithEncryptedCertificat
536
534
));
537
535
$ connector ->connect ($ server ->getAddress ());
538
536
539
- $ connection = Block \ await ($ peer , null , self ::TIMEOUT );
537
+ $ connection = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ peer , self ::TIMEOUT ) );
540
538
541
539
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
542
540
@@ -559,7 +557,7 @@ public function testClientRejectsWithErrorForServerWithInvalidCertificate()
559
557
$ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
560
558
561
559
try {
562
- Block \ await ($ promise , null , self ::TIMEOUT );
560
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
563
561
} catch (\Exception $ e ) {
564
562
$ server ->close ();
565
563
@@ -589,7 +587,7 @@ public function testServerEmitsErrorForClientWithInvalidCertificate()
589
587
$ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
590
588
591
589
try {
592
- Block \ await ($ peer , null , self ::TIMEOUT );
590
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ peer , self ::TIMEOUT ) );
593
591
} catch (\Exception $ e ) {
594
592
$ server ->close ();
595
593
@@ -618,7 +616,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateMissingPassphrase
618
616
$ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
619
617
620
618
try {
621
- Block \ await ($ promise , null , self ::TIMEOUT );
619
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
622
620
} catch (\Exception $ e ) {
623
621
$ server ->close ();
624
622
@@ -648,7 +646,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateWithInvalidPassph
648
646
$ this ->setExpectedException ('RuntimeException ' , 'handshake ' );
649
647
650
648
try {
651
- Block \ await ($ promise , null , self ::TIMEOUT );
649
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
652
650
} catch (\Exception $ e ) {
653
651
$ server ->close ();
654
652
@@ -671,7 +669,7 @@ public function testEmitsErrorForConnectionWithPeerVerification()
671
669
$ promise = $ connector ->connect ($ server ->getAddress ());
672
670
$ promise ->then (null , $ this ->expectCallableOnce ());
673
671
674
- Block \ await ($ errorEvent , null , self ::TIMEOUT );
672
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
675
673
676
674
$ server ->close ();
677
675
}
@@ -696,7 +694,7 @@ public function testEmitsErrorIfConnectionIsCancelled()
696
694
$ promise ->cancel ();
697
695
$ promise ->then (null , $ this ->expectCallableOnce ());
698
696
699
- Block \ await ($ errorEvent , null , self ::TIMEOUT );
697
+ \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
700
698
701
699
$ server ->close ();
702
700
}
@@ -717,7 +715,7 @@ public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()
717
715
$ stream ->close ();
718
716
});
719
717
720
- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
718
+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
721
719
722
720
// Connection from tcp://127.0.0.1:39528 failed during TLS handshake: Connection lost during TLS handshake (ECONNRESET)
723
721
$ this ->assertInstanceOf ('RuntimeException ' , $ error );
@@ -745,7 +743,7 @@ public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()
745
743
$ stream ->end ("\x1e" );
746
744
});
747
745
748
- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
746
+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
749
747
750
748
// Connection from tcp://127.0.0.1:39528 failed during TLS handshake: Connection lost during TLS handshake (ECONNRESET)
751
749
$ this ->assertInstanceOf ('RuntimeException ' , $ error );
@@ -769,7 +767,7 @@ public function testEmitsNothingIfPlaintextConnectionIsIdle()
769
767
$ connector = new TcpConnector ();
770
768
$ promise = $ connector ->connect (str_replace ('tls:// ' , '' , $ server ->getAddress ()));
771
769
772
- $ connection = Block \ await ($ promise , null , self ::TIMEOUT );
770
+ $ connection = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ promise , self ::TIMEOUT ) );
773
771
$ this ->assertInstanceOf ('React\Socket\ConnectionInterface ' , $ connection );
774
772
775
773
$ server ->close ();
@@ -794,7 +792,7 @@ public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()
794
792
$ stream ->write ("GET / HTTP/1.0 \r\n\r\n" );
795
793
});
796
794
797
- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
795
+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
798
796
799
797
$ this ->assertInstanceOf ('RuntimeException ' , $ error );
800
798
@@ -823,7 +821,7 @@ public function testEmitsErrorIfConnectionIsUnknownProtocolInsteadOfSecureHandsh
823
821
$ stream ->write ("Hello world! \n" );
824
822
});
825
823
826
- $ error = Block \ await ($ errorEvent , null , self ::TIMEOUT );
824
+ $ error = \ React \ Async \ await (\ React \ Promise \ Timer \timeout ( $ errorEvent , self ::TIMEOUT ) );
827
825
828
826
$ this ->assertInstanceOf ('RuntimeException ' , $ error );
829
827
0 commit comments