1515
1616class SecureIntegrationTest extends TestCase
1717{
18+ const TIMEOUT = 0.5 ;
19+
1820 private $ portSecure ;
1921 private $ portPlain ;
2022
@@ -51,7 +53,7 @@ public function tearDown()
5153
5254 public function testConnectToServer ()
5355 {
54- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
56+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
5557 /* @var $client Stream */
5658
5759 $ client ->close ();
@@ -63,7 +65,7 @@ public function testConnectToServerEmitsConnection()
6365
6466 $ promiseClient = $ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure );
6567
66- list ($ _ , $ client ) = Block \awaitAll (array ($ promiseServer , $ promiseClient ), $ this ->loop );
68+ list ($ _ , $ client ) = Block \awaitAll (array ($ promiseServer , $ promiseClient ), $ this ->loop , self :: TIMEOUT );
6769 /* @var $client Stream */
6870
6971 $ client ->close ();
@@ -79,13 +81,13 @@ public function testSendSmallDataToServerReceivesOneChunk()
7981 });
8082 });
8183
82- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
84+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
8385 /* @var $client Stream */
8486
8587 $ client ->write ('hello ' );
8688
8789 // await server to report one "data" event
88- $ data = Block \await ($ received ->promise (), $ this ->loop );
90+ $ data = Block \await ($ received ->promise (), $ this ->loop , self :: TIMEOUT );
8991
9092 $ client ->close ();
9193
@@ -105,14 +107,14 @@ public function testSendDataWithEndToServerReceivesAllData()
105107 });
106108 });
107109
108- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
110+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
109111 /* @var $client Stream */
110112
111113 $ data = str_repeat ('a ' , 200000 );
112114 $ client ->end ($ data );
113115
114116 // await server to report connection "close" event
115- $ received = Block \await ($ disconnected ->promise (), $ this ->loop );
117+ $ received = Block \await ($ disconnected ->promise (), $ this ->loop , self :: TIMEOUT );
116118
117119 $ this ->assertEquals ($ data , $ received );
118120 }
@@ -126,7 +128,7 @@ public function testSendDataWithoutEndingToServerReceivesAllData()
126128 });
127129 });
128130
129- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
131+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
130132 /* @var $client Stream */
131133
132134 $ data = str_repeat ('d ' , 200000 );
@@ -146,12 +148,12 @@ public function testConnectToServerWhichSendsSmallDataReceivesOneChunk()
146148 $ peer ->write ('hello ' );
147149 });
148150
149- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
151+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
150152 /* @var $client Stream */
151153
152154 // await client to report one "data" event
153155 $ receive = $ this ->createPromiseForEvent ($ client , 'data ' , $ this ->expectCallableOnceWith ('hello ' ));
154- Block \await ($ receive , $ this ->loop );
156+ Block \await ($ receive , $ this ->loop , self :: TIMEOUT );
155157
156158 $ client ->close ();
157159 }
@@ -163,11 +165,11 @@ public function testConnectToServerWhichSendsDataWithEndReceivesAllData()
163165 $ peer ->end ($ data );
164166 });
165167
166- $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
168+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop , self :: TIMEOUT );
167169 /* @var $client Stream */
168170
169171 // await data from client until it closes
170- $ received = Block \await (BufferedSink::createPromise ($ client ), $ this ->loop );
172+ $ received = Block \await (BufferedSink::createPromise ($ client ), $ this ->loop , self :: TIMEOUT );
171173
172174 $ this ->assertEquals ($ data , $ received );
173175 }
0 commit comments