1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 20:24:43 +01:00

Fix tests

This commit is contained in:
Niklas Keller 2018-07-12 08:28:31 +02:00
parent b0e690d3ee
commit 717dabc883
3 changed files with 9 additions and 2 deletions

View File

@ -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"
},

View File

@ -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) {

View File

@ -44,6 +44,7 @@ class ProcessTest extends TestCase
/** @noinspection PhpUnhandledExceptionInspection */
$process->start();
$process->getStdout()->read();
$code = $process->join();
$this->assertSame(42, $code);