bug #11381 [2.3] [Process] Use correct test for empty string in UnixPipes (whs, romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3] [Process] Use correct test for empty string in UnixPipes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This PR supersedes #11264 : 2.3 compatibility + Windows compatibility + CS fix Commits -------cec0a45
[Process] Adjust PR #11264, make it Windows compatible and fix CS9e1ea4a
[Process] Use correct test for empty string in UnixPipes
This commit is contained in:
commit
91e32f810b
@ -313,11 +313,11 @@ class ProcessPipes
|
|||||||
$type = array_search($pipe, $this->pipes);
|
$type = array_search($pipe, $this->pipes);
|
||||||
|
|
||||||
$data = '';
|
$data = '';
|
||||||
while ($dataread = fread($pipe, self::CHUNK_SIZE)) {
|
while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) {
|
||||||
$data .= $dataread;
|
$data .= $dataread;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data) {
|
if ('' !== $data) {
|
||||||
$read[$type] = $data;
|
$read[$type] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +287,19 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testZeroAsOutput()
|
||||||
|
{
|
||||||
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
// see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line
|
||||||
|
$p = $this->getProcess('echo | set /p dummyName=0');
|
||||||
|
} else {
|
||||||
|
$p = $this->getProcess('printf 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
$p->run();
|
||||||
|
$this->assertSame('0', $p->getOutput());
|
||||||
|
}
|
||||||
|
|
||||||
public function testExitCodeCommandFailed()
|
public function testExitCodeCommandFailed()
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
Reference in New Issue
Block a user