@@ -93,6 +93,21 @@ public function testSendSmallDataToServerReceivesOneChunk()
9393
9494 public function testSendDataWithEndToServerReceivesAllData ()
9595 {
96+ // PHP can report EOF on TLS 1.3 stream before consuming all data, so
97+ // we explicitly use older TLS version instead. Selecting TLS version
98+ // requires PHP 5.6+, so skip legacy versions if TLS 1.3 is supported.
99+ // Continue if TLS 1.3 is not supported anyway.
100+ if ($ this ->supportsTls13 ()) {
101+ if (!defined ('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT ' )) {
102+ $ this ->markTestSkipped ('TLS 1.3 supported, but this legacy PHP version does not support explicit choice ' );
103+ }
104+
105+ $ this ->connector = new SecureConnector (new TcpConnector ($ this ->loop ), $ this ->loop , array (
106+ 'verify_peer ' => false ,
107+ 'crypto_method ' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
108+ ));
109+ }
110+
96111 $ disconnected = new Deferred ();
97112 $ this ->server ->on ('connection ' , function (ConnectionInterface $ peer ) use ($ disconnected ) {
98113 $ received = '' ;
@@ -113,6 +128,7 @@ public function testSendDataWithEndToServerReceivesAllData()
113128 // await server to report connection "close" event
114129 $ received = Block \await ($ disconnected ->promise (), $ this ->loop , self ::TIMEOUT );
115130
131+ $ this ->assertEquals (strlen ($ data ), strlen ($ received ));
116132 $ this ->assertEquals ($ data , $ received );
117133 }
118134
@@ -136,6 +152,7 @@ public function testSendDataWithoutEndingToServerReceivesAllData()
136152
137153 $ client ->close ();
138154
155+ $ this ->assertEquals (strlen ($ data ), strlen ($ received ));
139156 $ this ->assertEquals ($ data , $ received );
140157 }
141158
0 commit comments