Skip to content

Commit

Permalink
Clean up event-loop leftovers in test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings committed Jan 13, 2022
1 parent 85a920a commit d846ea9
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 128 deletions.
14 changes: 7 additions & 7 deletions tests/FunctionalConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace React\Tests\Socket;

use Clue\React\Block;
use React\EventLoop\Factory;
use React\EventLoop\Loop;
use React\Promise\Deferred;
use React\Socket\ConnectionInterface;
use React\Socket\Connector;
Expand All @@ -20,7 +20,7 @@ class FunctionalConnectorTest extends TestCase
/** @test */
public function connectionToTcpServerShouldSucceedWithLocalhost()
{
$loop = Factory::create();
$loop = Loop::get();

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

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

$loop = Factory::create();
$loop = Loop::get();

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

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

$loop = Factory::create();
$loop = Loop::get();

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

Expand All @@ -99,7 +99,7 @@ public function connectionToRemoteTCP4n6ServerShouldResultInOurIP()
*/
public function connectionToRemoteTCP4ServerShouldResultInOurIP()
{
$loop = Factory::create();
$loop = Loop::get();

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

Expand All @@ -120,7 +120,7 @@ public function connectionToRemoteTCP4ServerShouldResultInOurIP()
*/
public function connectionToRemoteTCP6ServerShouldResultInOurIP()
{
$loop = Factory::create();
$loop = Loop::get();

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

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

$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$uri = str_replace('tcp://', 'tls://', $server->getAddress());
Expand Down
54 changes: 27 additions & 27 deletions tests/FunctionalSecureServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Clue\React\Block;
use Evenement\EventEmitterInterface;
use React\EventLoop\Factory;
use React\EventLoop\Loop;
use React\Promise\Promise;
use React\Socket\ConnectionInterface;
use React\Socket\SecureConnector;
Expand All @@ -29,7 +29,7 @@ public function setUpSkipTest()

public function testClientCanConnectToServer()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testClientUsesTls13ByDefaultWhenSupportedByOpenSSL()
$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');
}

$loop = Factory::create();
$loop = Loop::get();

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

$loop = Factory::create();
$loop = Loop::get();

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

$loop = Factory::create();
$loop = Loop::get();

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

$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -193,7 +193,7 @@ public function testClientUsesTls10WhenCryptoMethodIsExplicitlyConfiguredByClien

public function testServerEmitsConnectionForClientConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -232,7 +232,7 @@ public function testServerEmitsConnectionForClientConnection()

public function testClientEmitsDataEventOnceForDataWrittenFromServer()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -261,7 +261,7 @@ public function testClientEmitsDataEventOnceForDataWrittenFromServer()

public function testWritesDataInMultipleChunksToConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -298,7 +298,7 @@ public function testWritesDataInMultipleChunksToConnection()

public function testWritesMoreDataInMultipleChunksToConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -335,7 +335,7 @@ public function testWritesMoreDataInMultipleChunksToConnection()

public function testEmitsDataFromConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -363,7 +363,7 @@ public function testEmitsDataFromConnection()

public function testEmitsDataInMultipleChunksFromConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -398,7 +398,7 @@ public function testEmitsDataInMultipleChunksFromConnection()

public function testPipesDataBackInMultipleChunksFromConnection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -440,7 +440,7 @@ public function testPipesDataBackInMultipleChunksFromConnection()
*/
public function testEmitsConnectionForNewTlsv11Connection()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand All @@ -464,7 +464,7 @@ public function testEmitsConnectionForNewTlsv11Connection()
*/
public function testEmitsErrorForClientWithTlsVersionMismatch()
{
$loop = Factory::create();
$loop = Loop::get();

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

public function testServerEmitsConnectionForNewConnectionWithEncryptedCertificate()
{
$loop = Factory::create();
$loop = Loop::get();

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

public function testClientRejectsWithErrorForServerWithInvalidCertificate()
{
$loop = Factory::create();
$loop = Loop::get();

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

public function testServerEmitsErrorForClientWithInvalidCertificate()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -558,7 +558,7 @@ public function testEmitsErrorForServerWithEncryptedCertificateMissingPassphrase
$this->markTestSkipped('Not supported on Windows');
}

$loop = Factory::create();
$loop = Loop::get();

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

$loop = Factory::create();
$loop = Loop::get();

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

public function testEmitsErrorForConnectionWithPeerVerification()
{
$loop = Factory::create();
$loop = Loop::get();

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

$loop = Factory::create();
$loop = Loop::get();

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

public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -676,7 +676,7 @@ public function testEmitsErrorIfConnectionIsClosedBeforeHandshake()

public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -704,7 +704,7 @@ public function testEmitsErrorIfConnectionIsClosedWithIncompleteHandshake()

public function testEmitsNothingIfPlaintextConnectionIsIdle()
{
$loop = Factory::create();
$loop = Loop::get();

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

public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down Expand Up @@ -751,7 +751,7 @@ public function testEmitsErrorIfConnectionIsHttpInsteadOfSecureHandshake()

public function testEmitsErrorIfConnectionIsUnknownProtocolInsteadOfSecureHandshake()
{
$loop = Factory::create();
$loop = Loop::get();

$server = new TcpServer(0, $loop);
$server = new SecureServer($server, $loop, array(
Expand Down
Loading

0 comments on commit d846ea9

Please sign in to comment.