diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bfdeecf6..19a4b901 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,8 +4,9 @@ + convertDeprecationsToExceptions="true"> ./tests/ diff --git a/tests/AbstractLoopTest.php b/tests/AbstractLoopTest.php index 61790882..5b4da29e 100644 --- a/tests/AbstractLoopTest.php +++ b/tests/AbstractLoopTest.php @@ -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; /** diff --git a/tests/ExtEventLoopTest.php b/tests/ExtEventLoopTest.php index 2f88d184..af4caa13 100644 --- a/tests/ExtEventLoopTest.php +++ b/tests/ExtEventLoopTest.php @@ -6,6 +6,9 @@ class ExtEventLoopTest extends AbstractLoopTest { + /** @var ?string */ + private $fifoPath; + public function createLoop($readStreamCompatible = false) { if ('Linux' === PHP_OS && !extension_loaded('posix')) { @@ -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); diff --git a/tests/ExtLibeventLoopTest.php b/tests/ExtLibeventLoopTest.php index 32a852b8..524e0548 100644 --- a/tests/ExtLibeventLoopTest.php +++ b/tests/ExtLibeventLoopTest.php @@ -6,6 +6,7 @@ class ExtLibeventLoopTest extends AbstractLoopTest { + /** @var ?string */ private $fifoPath; public function createLoop() @@ -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); } } @@ -38,6 +39,7 @@ public function createStream() } $this->fifoPath = tempnam(sys_get_temp_dir(), 'react-'); + assert(is_string($this->fifoPath)); unlink($this->fifoPath); diff --git a/tests/bin/01-ticks-loop-class.php b/tests/bin/01-ticks-loop-class.php index f4fcedf1..5d499f92 100644 --- a/tests/bin/01-ticks-loop-class.php +++ b/tests/bin/01-ticks-loop-class.php @@ -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'; diff --git a/tests/bin/02-ticks-loop-instance.php b/tests/bin/02-ticks-loop-instance.php index 57e58c92..5aeead84 100644 --- a/tests/bin/02-ticks-loop-instance.php +++ b/tests/bin/02-ticks-loop-instance.php @@ -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(); diff --git a/tests/bin/03-ticks-loop-stop.php b/tests/bin/03-ticks-loop-stop.php index d8b65946..87317563 100644 --- a/tests/bin/03-ticks-loop-stop.php +++ b/tests/bin/03-ticks-loop-stop.php @@ -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(); diff --git a/tests/bin/11-uncaught.php b/tests/bin/11-uncaught.php index 0655698b..c5bf8c70 100644 --- a/tests/bin/11-uncaught.php +++ b/tests/bin/11-uncaught.php @@ -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'; diff --git a/tests/bin/12-undefined.php b/tests/bin/12-undefined.php index 66d0d726..c45cc0f4 100644 --- a/tests/bin/12-undefined.php +++ b/tests/bin/12-undefined.php @@ -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'; diff --git a/tests/bin/21-stop.php b/tests/bin/21-stop.php index 038d9223..182ee016 100644 --- a/tests/bin/21-stop.php +++ b/tests/bin/21-stop.php @@ -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'; diff --git a/tests/bin/22-stop-uncaught.php b/tests/bin/22-stop-uncaught.php index f0c0ff8d..5b6142ed 100644 --- a/tests/bin/22-stop-uncaught.php +++ b/tests/bin/22-stop-uncaught.php @@ -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';