Skip to content

Commit d846ea9

Browse files
committed
Clean up event-loop leftovers in test classes
1 parent 85a920a commit d846ea9

13 files changed

+127
-128
lines changed

tests/FunctionalConnectorTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace React\Tests\Socket;
44

55
use Clue\React\Block;
6-
use React\EventLoop\Factory;
6+
use React\EventLoop\Loop;
77
use React\Promise\Deferred;
88
use React\Socket\ConnectionInterface;
99
use React\Socket\Connector;
@@ -20,7 +20,7 @@ class FunctionalConnectorTest extends TestCase
2020
/** @test */
2121
public function connectionToTcpServerShouldSucceedWithLocalhost()
2222
{
23-
$loop = Factory::create();
23+
$loop = Loop::get();
2424

2525
$server = new TcpServer(9998, $loop);
2626

@@ -44,7 +44,7 @@ public function testConnectTwiceWithoutHappyEyeBallsOnlySendsSingleDnsQueryDueTo
4444
$this->markTestSkipped('Not supported on Windows for PHP versions < 7.0 and legacy HHVM');
4545
}
4646

47-
$loop = Factory::create();
47+
$loop = Loop::get();
4848

4949
$socket = stream_socket_server('udp://127.0.0.1:0', $errno, $errstr, STREAM_SERVER_BIND);
5050

@@ -84,7 +84,7 @@ public function connectionToRemoteTCP4n6ServerShouldResultInOurIP()
8484
// max_nesting_level was set to 100 for PHP Versions < 5.4 which resulted in failing test for legacy PHP
8585
ini_set('xdebug.max_nesting_level', 256);
8686

87-
$loop = Factory::create();
87+
$loop = Loop::get();
8888

8989
$connector = new Connector(array('happy_eyeballs' => true), $loop);
9090

@@ -99,7 +99,7 @@ public function connectionToRemoteTCP4n6ServerShouldResultInOurIP()
9999
*/
100100
public function connectionToRemoteTCP4ServerShouldResultInOurIP()
101101
{
102-
$loop = Factory::create();
102+
$loop = Loop::get();
103103

104104
$connector = new Connector(array('happy_eyeballs' => true), $loop);
105105

@@ -120,7 +120,7 @@ public function connectionToRemoteTCP4ServerShouldResultInOurIP()
120120
*/
121121
public function connectionToRemoteTCP6ServerShouldResultInOurIP()
122122
{
123-
$loop = Factory::create();
123+
$loop = Loop::get();
124124

125125
$connector = new Connector(array('happy_eyeballs' => true), $loop);
126126

@@ -141,7 +141,7 @@ public function testCancelPendingTlsConnectionDuringTlsHandshakeShouldCloseTcpCo
141141
$this->markTestSkipped('Not supported on legacy HHVM');
142142
}
143143

144-
$loop = Factory::create();
144+
$loop = Loop::get();
145145

146146
$server = new TcpServer(0, $loop);
147147
$uri = str_replace('tcp://', 'tls://', $server->getAddress());

tests/FunctionalSecureServerTest.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Clue\React\Block;
66
use Evenement\EventEmitterInterface;
7-
use React\EventLoop\Factory;
7+
use React\EventLoop\Loop;
88
use React\Promise\Promise;
99
use React\Socket\ConnectionInterface;
1010
use React\Socket\SecureConnector;
@@ -29,7 +29,7 @@ public function setUpSkipTest()
2929

3030
public function testClientCanConnectToServer()
3131
{
32-
$loop = Factory::create();
32+
$loop = Loop::get();
3333

3434
$server = new TcpServer(0, $loop);
3535
$server = new SecureServer($server, $loop, array(
@@ -60,7 +60,7 @@ public function testClientUsesTls13ByDefaultWhenSupportedByOpenSSL()
6060
$this->markTestSkipped('Test requires PHP 7+ for crypto meta data (but excludes PHP 7.3 because it implicitly limits to TLS 1.2) and OpenSSL 1.1.1+ for TLS 1.3');
6161
}
6262

63-
$loop = Factory::create();
63+
$loop = Loop::get();
6464

6565
$server = new TcpServer(0, $loop);
6666
$server = new SecureServer($server, $loop, array(
@@ -97,7 +97,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByClien
9797
$this->markTestSkipped('Test requires PHP 7+ for crypto meta data');
9898
}
9999

100-
$loop = Factory::create();
100+
$loop = Loop::get();
101101

102102
$server = new TcpServer(0, $loop);
103103
$server = new SecureServer($server, $loop, array(
@@ -127,7 +127,7 @@ public function testClientUsesTls12WhenCryptoMethodIsExplicitlyConfiguredByServe
127127
$this->markTestSkipped('Test requires PHP 7+ for crypto meta data');
128128
}
129129

130-
$loop = Factory::create();
130+
$loop = Loop::get();
131131

132132
$server = new TcpServer(0, $loop);
133133
$server = new SecureServer($server, $loop, array(
@@ -157,7 +157,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien
157157
$this->markTestSkipped('Test requires PHP 7+ for crypto meta data');
158158
}
159159

160-
$loop = Factory::create();
160+
$loop = Loop::get();
161161

162162
$server = new TcpServer(0, $loop);
163163
$server = new SecureServer($server, $loop, array(
@@ -193,7 +193,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien
193193

194194
public function testServerEmitsConnectionForClientConnection()
195195
{
196-
$loop = Factory::create();
196+
$loop = Loop::get();
197197

198198
$server = new TcpServer(0, $loop);
199199
$server = new SecureServer($server, $loop, array(
@@ -232,7 +232,7 @@ public function testServerEmitsConnectionForClientConnection()
232232

233233
public function testClientEmitsDataEventOnceForDataWrittenFromServer()
234234
{
235-
$loop = Factory::create();
235+
$loop = Loop::get();
236236

237237
$server = new TcpServer(0, $loop);
238238
$server = new SecureServer($server, $loop, array(
@@ -261,7 +261,7 @@ public function testClientEmitsDataEventOnceForDataWrittenFromServer()
261261

262262
public function testWritesDataInMultipleChunksToConnection()
263263
{
264-
$loop = Factory::create();
264+
$loop = Loop::get();
265265

266266
$server = new TcpServer(0, $loop);
267267
$server = new SecureServer($server, $loop, array(
@@ -298,7 +298,7 @@ public function testWritesDataInMultipleChunksToConnection()
298298

299299
public function testWritesMoreDataInMultipleChunksToConnection()
300300
{
301-
$loop = Factory::create();
301+
$loop = Loop::get();
302302

303303
$server = new TcpServer(0, $loop);
304304
$server = new SecureServer($server, $loop, array(
@@ -335,7 +335,7 @@ public function testWritesMoreDataInMultipleChunksToConnection()
335335

336336
public function testEmitsDataFromConnection()
337337
{
338-
$loop = Factory::create();
338+
$loop = Loop::get();
339339

340340
$server = new TcpServer(0, $loop);
341341
$server = new SecureServer($server, $loop, array(
@@ -363,7 +363,7 @@ public function testEmitsDataFromConnection()
363363

364364
public function testEmitsDataInMultipleChunksFromConnection()
365365
{
366-
$loop = Factory::create();
366+
$loop = Loop::get();
367367

368368
$server = new TcpServer(0, $loop);
369369
$server = new SecureServer($server, $loop, array(
@@ -398,7 +398,7 @@ public function testEmitsDataInMultipleChunksFromConnection()
398398

399399
public function testPipesDataBackInMultipleChunksFromConnection()
400400
{
401-
$loop = Factory::create();
401+
$loop = Loop::get();
402402

403403
$server = new TcpServer(0, $loop);
404404
$server = new SecureServer($server, $loop, array(
@@ -440,7 +440,7 @@ public function testPipesDataBackInMultipleChunksFromConnection()
440440
*/
441441
public function testEmitsConnectionForNewTlsv11Connection()
442442
{
443-
$loop = Factory::create();
443+
$loop = Loop::get();
444444

445445
$server = new TcpServer(0, $loop);
446446
$server = new SecureServer($server, $loop, array(
@@ -464,7 +464,7 @@ public function testEmitsConnectionForNewTlsv11Connection()
464464
*/
465465
public function testEmitsErrorForClientWithTlsVersionMismatch()
466466
{
467-
$loop = Factory::create();
467+
$loop = Loop::get();
468468

469469
$server = new TcpServer(0, $loop);
470470
$server = new SecureServer($server, $loop, array(
@@ -486,7 +486,7 @@ public function testEmitsErrorForClientWithTlsVersionMismatch()
486486

487487
public function testServerEmitsConnectionForNewConnectionWithEncryptedCertificate()
488488
{
489-
$loop = Factory::create();
489+
$loop = Loop::get();
490490

491491
$server = new TcpServer(0, $loop);
492492
$server = new SecureServer($server, $loop, array(
@@ -511,7 +511,7 @@ public function testServerEmitsConnectionForNewConnectionWithEncryptedCertificat
511511

512512
public function testClientRejectsWithErrorForServerWithInvalidCertificate()
513513
{
514-
$loop = Factory::create();
514+
$loop = Loop::get();
515515

516516
$server = new TcpServer(0, $loop);
517517
$server = new SecureServer($server, $loop, array(
@@ -529,7 +529,7 @@ public function testClientRejectsWithErrorForServerWithInvalidCertificate()
529529

530530
public function testServerEmitsErrorForClientWithInvalidCertificate()
531531
{
532-
$loop = Factory::create();
532+
$loop = Loop::get();
533533

534534
$server = new TcpServer(0, $loop);
535535
$server = new SecureServer($server, $loop, array(
@@ -558,7 +558,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateMissingPassphrase
558558
$this->markTestSkipped('Not supported on Windows');
559559
}
560560

561-
$loop = Factory::create();
561+
$loop = Loop::get();
562562

563563
$server = new TcpServer(0, $loop);
564564
$server = new SecureServer($server, $loop, array(
@@ -582,7 +582,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateWithInvalidPassph
582582
$this->markTestSkipped('Not supported on Windows');
583583
}
584584

585-
$loop = Factory::create();
585+
$loop = Loop::get();
586586

587587
$server = new TcpServer(0, $loop);
588588
$server = new SecureServer($server, $loop, array(
@@ -603,7 +603,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateWithInvalidPassph
603603

604604
public function testEmitsErrorForConnectionWithPeerVerification()
605605
{
606-
$loop = Factory::create();
606+
$loop = Loop::get();
607607

608608
$server = new TcpServer(0, $loop);
609609
$server = new SecureServer($server, $loop, array(
@@ -627,7 +627,7 @@ public function testEmitsErrorIfConnectionIsCancelled()
627627
$this->markTestSkipped('Linux only (OS is ' . PHP_OS . ')');
628628
}
629629

630-
$loop = Factory::create();
630+
$loop = Loop::get();
631631

632632
$server = new TcpServer(0, $loop);
633633
$server = new SecureServer($server, $loop, array(
@@ -648,7 +648,7 @@ public function testEmitsErrorIfConnectionIsCancelled()
648648

649649
public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()
650650
{
651-
$loop = Factory::create();
651+
$loop = Loop::get();
652652

653653
$server = new TcpServer(0, $loop);
654654
$server = new SecureServer($server, $loop, array(
@@ -676,7 +676,7 @@ public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()
676676

677677
public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()
678678
{
679-
$loop = Factory::create();
679+
$loop = Loop::get();
680680

681681
$server = new TcpServer(0, $loop);
682682
$server = new SecureServer($server, $loop, array(
@@ -704,7 +704,7 @@ public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()
704704

705705
public function testEmitsNothingIfPlaintextConnectionIsIdle()
706706
{
707-
$loop = Factory::create();
707+
$loop = Loop::get();
708708

709709
$server = new TcpServer(0, $loop);
710710
$server = new SecureServer($server, $loop, array(
@@ -722,7 +722,7 @@ public function testEmitsNothingIfPlaintextConnectionIsIdle()
722722

723723
public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()
724724
{
725-
$loop = Factory::create();
725+
$loop = Loop::get();
726726

727727
$server = new TcpServer(0, $loop);
728728
$server = new SecureServer($server, $loop, array(
@@ -751,7 +751,7 @@ public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()
751751

752752
public function testEmitsErrorIfConnectionIsUnknownProtocolInsteadOfSecureHandshake()
753753
{
754-
$loop = Factory::create();
754+
$loop = Loop::get();
755755

756756
$server = new TcpServer(0, $loop);
757757
$server = new SecureServer($server, $loop, array(

0 commit comments

Comments
 (0)