Skip to content
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

Improve test suite to declare and validate helper variables and support running from meta repository (PHP 8.1) #242

Merged
merged 2 commits into from Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Expand Up @@ -4,8 +4,9 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
cacheResult="false">
convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="React test suite">
<directory>./tests/</directory>
Expand Down
4 changes: 4 additions & 0 deletions tests/AbstractLoopTest.php
Expand Up @@ -12,8 +12,12 @@ abstract class AbstractLoopTest extends TestCase
*/
protected $loop;

/** @var float */
private $tickTimeout;

/** @var ?string */
private $received;

const PHP_DEFAULT_CHUNK_SIZE = 8192;

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/ExtEventLoopTest.php
Expand Up @@ -6,6 +6,9 @@

class ExtEventLoopTest extends AbstractLoopTest
{
/** @var ?string */
private $fifoPath;

public function createLoop($readStreamCompatible = false)
{
if ('Linux' === PHP_OS && !extension_loaded('posix')) {
Expand All @@ -19,12 +22,23 @@ public function createLoop($readStreamCompatible = false)
return new ExtEventLoop();
}

/**
* @after
*/
public function tearDownFile()
{
if ($this->fifoPath !== null && file_exists($this->fifoPath)) {
unlink($this->fifoPath);
}
}

public function createStream()
{
// Use a FIFO on linux to get around lack of support for disk-based file
// descriptors when using the EPOLL back-end.
if ('Linux' === PHP_OS) {
$this->fifoPath = tempnam(sys_get_temp_dir(), 'react-');
assert(is_string($this->fifoPath));

unlink($this->fifoPath);

Expand Down
4 changes: 3 additions & 1 deletion tests/ExtLibeventLoopTest.php
Expand Up @@ -6,6 +6,7 @@

class ExtLibeventLoopTest extends AbstractLoopTest
{
/** @var ?string */
private $fifoPath;

public function createLoop()
Expand All @@ -26,7 +27,7 @@ public function createLoop()
*/
public function tearDownFile()
{
if (file_exists($this->fifoPath)) {
if ($this->fifoPath !== null && file_exists($this->fifoPath)) {
unlink($this->fifoPath);
}
}
Expand All @@ -38,6 +39,7 @@ public function createStream()
}

$this->fifoPath = tempnam(sys_get_temp_dir(), 'react-');
assert(is_string($this->fifoPath));

unlink($this->fifoPath);

Expand Down
3 changes: 2 additions & 1 deletion tests/bin/01-ticks-loop-class.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

Loop::futureTick(function () {
echo 'b';
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/02-ticks-loop-instance.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

$loop = Loop::get();

Expand Down
3 changes: 2 additions & 1 deletion tests/bin/03-ticks-loop-stop.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

$loop = Loop::get();

Expand Down
3 changes: 2 additions & 1 deletion tests/bin/11-uncaught.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

Loop::addTimer(10.0, function () {
echo 'never';
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/12-undefined.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

Loop::get()->addTimer(10.0, function () {
echo 'never';
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/21-stop.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

Loop::addTimer(10.0, function () {
echo 'never';
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/22-stop-uncaught.php
Expand Up @@ -2,7 +2,8 @@

use React\EventLoop\Loop;

require __DIR__ . '/../../vendor/autoload.php';
// autoload for local project development or project installed as dependency for reactphp/reactphp
(@include __DIR__ . '/../../vendor/autoload.php') || require __DIR__ . '/../../../../autoload.php';

Loop::addTimer(10.0, function () {
echo 'never';
Expand Down