From 717dabc8832370ccc526d32552c765bece726aff Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Thu, 12 Jul 2018 08:28:31 +0200 Subject: [PATCH] Fix tests --- composer.json | 2 +- lib/ProcessInputStream.php | 8 +++++++- test/ProcessTest.php | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index cdbe601..38970f0 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "homepage": "https://github.com/amphp/process", "description": "Asynchronous process manager.", "require": { - "php": ">=7", + "php": ">=7.2", "amphp/amp": "dev-ext-task", "amphp/byte-stream": "dev-ext-task" }, diff --git a/lib/ProcessInputStream.php b/lib/ProcessInputStream.php index 1dce6d1..72f10d5 100644 --- a/lib/ProcessInputStream.php +++ b/lib/ProcessInputStream.php @@ -53,6 +53,9 @@ class ProcessInputStream implements InputStream if ($this->shouldClose) { if ($this->resourceStream->getResource()) { $this->buffer .= \stream_get_contents($this->resourceStream->getResource()); + if ($this->buffer === "") { + $this->buffer = null; + } } $this->resourceStream->close(); @@ -125,8 +128,11 @@ class ProcessInputStream implements InputStream { $this->shouldClose = true; - if ($this->resourceStream->getResource()) { + if ($this->resourceStream && $this->resourceStream->getResource()) { $this->buffer .= \stream_get_contents($this->resourceStream->getResource()); + if ($this->buffer === "") { + $this->buffer = null; + } } if ($this->initialRead) { diff --git a/test/ProcessTest.php b/test/ProcessTest.php index 1ad4dbf..7297d43 100644 --- a/test/ProcessTest.php +++ b/test/ProcessTest.php @@ -44,6 +44,7 @@ class ProcessTest extends TestCase /** @noinspection PhpUnhandledExceptionInspection */ $process->start(); + $process->getStdout()->read(); $code = $process->join(); $this->assertSame(42, $code);