15
15
16
16
class SecureIntegrationTest extends TestCase
17
17
{
18
+ const TIMEOUT = 0.5 ;
19
+
18
20
private $ portSecure ;
19
21
private $ portPlain ;
20
22
@@ -51,7 +53,7 @@ public function tearDown()
51
53
52
54
public function testConnectToServer ()
53
55
{
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 );
55
57
/* @var $client Stream */
56
58
57
59
$ client ->close ();
@@ -63,7 +65,7 @@ public function testConnectToServerEmitsConnection()
63
65
64
66
$ promiseClient = $ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure );
65
67
66
- list ($ _ , $ client ) = Block \awaitAll (array ($ promiseServer , $ promiseClient ), $ this ->loop );
68
+ list ($ _ , $ client ) = Block \awaitAll (array ($ promiseServer , $ promiseClient ), $ this ->loop , self :: TIMEOUT );
67
69
/* @var $client Stream */
68
70
69
71
$ client ->close ();
@@ -79,13 +81,13 @@ public function testSendSmallDataToServerReceivesOneChunk()
79
81
});
80
82
});
81
83
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 );
83
85
/* @var $client Stream */
84
86
85
87
$ client ->write ('hello ' );
86
88
87
89
// 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 );
89
91
90
92
$ client ->close ();
91
93
@@ -105,14 +107,14 @@ public function testSendDataWithEndToServerReceivesAllData()
105
107
});
106
108
});
107
109
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 );
109
111
/* @var $client Stream */
110
112
111
113
$ data = str_repeat ('a ' , 200000 );
112
114
$ client ->end ($ data );
113
115
114
116
// 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 );
116
118
117
119
$ this ->assertEquals ($ data , $ received );
118
120
}
@@ -126,7 +128,7 @@ public function testSendDataWithoutEndingToServerReceivesAllData()
126
128
});
127
129
});
128
130
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 );
130
132
/* @var $client Stream */
131
133
132
134
$ data = str_repeat ('d ' , 200000 );
@@ -146,12 +148,12 @@ public function testConnectToServerWhichSendsSmallDataReceivesOneChunk()
146
148
$ peer ->write ('hello ' );
147
149
});
148
150
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 );
150
152
/* @var $client Stream */
151
153
152
154
// await client to report one "data" event
153
155
$ receive = $ this ->createPromiseForEvent ($ client , 'data ' , $ this ->expectCallableOnceWith ('hello ' ));
154
- Block \await ($ receive , $ this ->loop );
156
+ Block \await ($ receive , $ this ->loop , self :: TIMEOUT );
155
157
156
158
$ client ->close ();
157
159
}
@@ -163,11 +165,11 @@ public function testConnectToServerWhichSendsDataWithEndReceivesAllData()
163
165
$ peer ->end ($ data );
164
166
});
165
167
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 );
167
169
/* @var $client Stream */
168
170
169
171
// 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 );
171
173
172
174
$ this ->assertEquals ($ data , $ received );
173
175
}
0 commit comments