1
0
mirror of https://github.com/danog/process.git synced 2024-11-30 04:39:04 +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", "homepage": "https://github.com/amphp/process",
"description": "Asynchronous process manager.", "description": "Asynchronous process manager.",
"require": { "require": {
"php": ">=7", "php": ">=7.2",
"amphp/amp": "dev-ext-task", "amphp/amp": "dev-ext-task",
"amphp/byte-stream": "dev-ext-task" "amphp/byte-stream": "dev-ext-task"
}, },

View File

@ -53,6 +53,9 @@ class ProcessInputStream implements InputStream
if ($this->shouldClose) { if ($this->shouldClose) {
if ($this->resourceStream->getResource()) { if ($this->resourceStream->getResource()) {
$this->buffer .= \stream_get_contents($this->resourceStream->getResource()); $this->buffer .= \stream_get_contents($this->resourceStream->getResource());
if ($this->buffer === "") {
$this->buffer = null;
}
} }
$this->resourceStream->close(); $this->resourceStream->close();
@ -125,8 +128,11 @@ class ProcessInputStream implements InputStream
{ {
$this->shouldClose = true; $this->shouldClose = true;
if ($this->resourceStream->getResource()) { if ($this->resourceStream && $this->resourceStream->getResource()) {
$this->buffer .= \stream_get_contents($this->resourceStream->getResource()); $this->buffer .= \stream_get_contents($this->resourceStream->getResource());
if ($this->buffer === "") {
$this->buffer = null;
}
} }
if ($this->initialRead) { if ($this->initialRead) {

View File

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