Skip to content

Use default loop in testsuite and close server and connection leftovers #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clean up event-loop leftovers in test classes
  • Loading branch information
SimonFrings committed Jan 13, 2022
commit d846ea9380f08c640a719c50af223ef2569eeb9d
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy