@@ -117,6 +117,29 @@ public function testSendDataWithEndToServerReceivesAllData()
117
117
$ this ->assertEquals ($ data , $ received );
118
118
}
119
119
120
+ public function testSendDataWithoutEndingToServerReceivesAllData ()
121
+ {
122
+ $ received = '' ;
123
+ $ this ->server ->on ('connection ' , function (Stream $ peer ) use (&$ received ) {
124
+ $ peer ->on ('data ' , function ($ chunk ) use (&$ received ) {
125
+ $ received .= $ chunk ;
126
+ });
127
+ });
128
+
129
+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
130
+ /* @var $client Stream */
131
+
132
+ $ data = str_repeat ('d ' , 200000 );
133
+ $ client ->write ($ data );
134
+
135
+ // buffer incoming data for 0.1s (should be plenty of time)
136
+ Block \sleep (0.1 , $ this ->loop );
137
+
138
+ $ client ->close ();
139
+
140
+ $ this ->assertEquals ($ data , $ received );
141
+ }
142
+
120
143
public function testConnectToServerWhichSendsSmallDataReceivesOneChunk ()
121
144
{
122
145
$ this ->server ->on ('connection ' , function (Stream $ peer ) {
@@ -149,6 +172,28 @@ public function testConnectToServerWhichSendsDataWithEndReceivesAllData()
149
172
$ this ->assertEquals ($ data , $ received );
150
173
}
151
174
175
+ public function testConnectToServerWhichSendsDataWithoutEndingReceivesAllData ()
176
+ {
177
+ $ data = str_repeat ('c ' , 100000 );
178
+ $ this ->server ->on ('connection ' , function (Stream $ peer ) use ($ data ) {
179
+ $ peer ->write ($ data );
180
+ });
181
+
182
+ $ client = Block \await ($ this ->connector ->create ('127.0.0.1 ' , $ this ->portSecure ), $ this ->loop );
183
+ /* @var $client Stream */
184
+
185
+ // buffer incoming data for 0.1s (should be plenty of time)
186
+ $ received = '' ;
187
+ $ client ->on ('data ' , function ($ chunk ) use (&$ received ) {
188
+ $ received .= $ chunk ;
189
+ });
190
+ Block \sleep (0.1 , $ this ->loop );
191
+
192
+ $ client ->close ();
193
+
194
+ $ this ->assertEquals ($ data , $ received );
195
+ }
196
+
152
197
private function createPromiseForEvent (EventEmitterInterface $ emitter , $ event , $ fn )
153
198
{
154
199
return new Promise (function ($ resolve ) use ($ emitter , $ event , $ fn ) {
0 commit comments