Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml

View file

@ -37,7 +37,7 @@ class PhpExecutableFinder
{
// HHVM support
if (defined('HHVM_VERSION')) {
return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
return (getenv('PHP_BINARY') ?: PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
}
// PHP_BINARY return the current sapi executable

View file

@ -1069,7 +1069,7 @@ class Process
*/
public function getStdin()
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the getInput() method instead.', E_USER_DEPRECATED);
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the getInput() method instead.', E_USER_DEPRECATED);
return $this->getInput();
}
@ -1099,7 +1099,7 @@ class Process
*/
public function setStdin($stdin)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the setInput() method instead.', E_USER_DEPRECATED);
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the setInput() method instead.', E_USER_DEPRECATED);
return $this->setInput($stdin);
}

View file

@ -49,7 +49,7 @@ class ProcessUtils
$escapedArgument = '';
$quote = false;
foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
if ('"' === $part) {
$escapedArgument .= '\\"';
} elseif (self::isSurroundedBy($part, '%')) {
@ -97,7 +97,7 @@ class ProcessUtils
}
// deprecated as of Symfony 2.5, to be removed in 3.0
if (is_object($input) && method_exists($input, '__toString')) {
trigger_error('Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
@trigger_error('Passing an object as an input is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
return (string) $input;
}

View file

@ -11,21 +11,30 @@
namespace Symfony\Component\Process\Tests;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Exception\LogicException;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Pipes\PipesInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\RuntimeException;
/**
* @author Robert Schönthal <seroscho@googlemail.com>
*/
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
{
protected static $phpBin;
public static function setUpBeforeClass()
{
$phpBin = new PhpExecutableFinder();
self::$phpBin = $phpBin->find();
}
public function testThatProcessDoesNotThrowWarningDuringRun()
{
@trigger_error('Test Error', E_USER_NOTICE);
$process = $this->getProcess("php -r 'sleep(3)'");
$process = $this->getProcess(self::$phpBin." -r 'sleep(3)'");
$process->run();
$actualError = error_get_last();
$this->assertEquals('Test Error', $actualError['message']);
@ -95,7 +104,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$expectedOutputSize = PipesInterface::CHUNK_SIZE * 2 + 2;
$code = sprintf('echo str_repeat(\'*\', %d);', $expectedOutputSize);
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p->start();
// Let's wait enough time for process to finish...
@ -134,7 +143,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testProcessResponses($expected, $getter, $code)
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p->run();
$this->assertSame($expected, $p->$getter());
@ -150,7 +159,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$expected = str_repeat(str_repeat('*', 1024), $size).'!';
$expectedLength = (1024 * $size) + 1;
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p->setInput($expected);
$p->run();
@ -170,7 +179,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
fwrite($stream, $expected);
rewind($stream);
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p->setInput($stream);
$p->run();
@ -182,7 +191,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testSetInputWhileRunningThrowsAnException()
{
$process = $this->getProcess('php -r "usleep(500000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$process->start();
try {
$process->setInput('foobar');
@ -201,7 +210,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidInput($value)
{
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->setInput($value);
}
@ -218,7 +227,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testValidInput($expected, $value)
{
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->setInput($value);
$this->assertSame($expected, $process->getInput());
}
@ -238,9 +247,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidInput($expected, $value)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->setInput($value);
$this->assertSame($expected, $process->getInput());
}
@ -278,7 +285,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testCallbackIsExecutedForOutput()
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('echo \'foo\';')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('echo \'foo\';')));
$called = false;
$p->run(function ($type, $buffer) use (&$called) {
@ -290,7 +297,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetErrorOutput()
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p->run();
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
@ -303,7 +310,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
file_put_contents($lock, 'W');
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p->start();
while ($p->isRunning()) {
@ -319,7 +326,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testFlushErrorOutput()
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p->run();
$p->clearErrorOutput();
@ -333,7 +340,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
file_put_contents($lock, 'W');
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p->start();
@ -359,7 +366,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetOutput()
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { echo \' foo \'; $n++; }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { echo \' foo \'; $n++; }')));
$p->run();
$this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches));
@ -372,7 +379,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
file_put_contents($lock, 'W');
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p->start();
while ($p->isRunning()) {
@ -388,7 +395,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testFlushOutput()
{
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++;}')));
$p->run();
$p->clearOutput();
@ -402,7 +409,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
file_put_contents($lock, 'W');
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
$p->start();
@ -548,7 +555,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testStartIsNonBlocking()
{
$process = $this->getProcess('php -r "usleep(500000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$start = microtime(true);
$process->start();
$end = microtime(true);
@ -558,14 +565,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testUpdateStatus()
{
$process = $this->getProcess('php -h');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertTrue(strlen($process->getOutput()) > 0);
}
public function testGetExitCodeIsNullOnStart()
{
$process = $this->getProcess('php -r "usleep(200000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
$this->assertNull($process->getExitCode());
$process->start();
$this->assertNull($process->getExitCode());
@ -575,7 +582,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetExitCodeIsNullOnWhenStartingAgain()
{
$process = $this->getProcess('php -r "usleep(200000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
$process->run();
$this->assertEquals(0, $process->getExitCode());
$process->start();
@ -586,14 +593,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetExitCode()
{
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertSame(0, $process->getExitCode());
}
public function testStatus()
{
$process = $this->getProcess('php -r "usleep(500000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$this->assertFalse($process->isRunning());
$this->assertFalse($process->isStarted());
$this->assertFalse($process->isTerminated());
@ -612,7 +619,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testStop()
{
$process = $this->getProcess('php -r "sleep(4);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
$process->start();
$this->assertTrue($process->isRunning());
$process->stop();
@ -621,14 +628,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testIsSuccessful()
{
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertTrue($process->isSuccessful());
}
public function testIsSuccessfulOnlyAfterTerminated()
{
$process = $this->getProcess('php -r "sleep(1);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
$process->start();
while ($process->isRunning()) {
$this->assertFalse($process->isSuccessful());
@ -640,7 +647,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testIsNotSuccessful()
{
$process = $this->getProcess('php -r "usleep(500000);throw new \Exception(\'BOUM\');"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);throw new \Exception(\'BOUM\');"');
$process->start();
$this->assertTrue($process->isRunning());
$process->wait();
@ -653,7 +660,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Windows does not support POSIX signals');
}
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertFalse($process->hasBeenSignaled());
}
@ -664,7 +671,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Windows does not support POSIX signals');
}
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertFalse($process->hasBeenSignaled());
}
@ -675,7 +682,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Windows does not support POSIX signals');
}
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertEquals(0, $process->getTermSignal());
}
@ -686,7 +693,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Windows does not support POSIX signals');
}
$process = $this->getProcess('php -r "sleep(4);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
$process->start();
$process->stop();
$this->assertTrue($process->hasBeenSignaled());
@ -701,7 +708,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
// SIGTERM is only defined if pcntl extension is present
$termSignal = defined('SIGTERM') ? SIGTERM : 15;
$process = $this->getProcess('php -r "sleep(4);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
$process->start();
$process->stop();
@ -730,7 +737,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testRestart()
{
$process1 = $this->getProcess('php -r "echo getmypid();"');
$process1 = $this->getProcess(self::$phpBin.' -r "echo getmypid();"');
$process1->run();
$process2 = $process1->restart();
@ -752,7 +759,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
// Sleep doesn't work as it will allow the process to handle signals and close
// file handles from the other end.
$process = $this->getProcess('php -r "while (true) {}"');
$process = $this->getProcess(self::$phpBin.' -r "while (true) {}"');
$process->start();
// PHP will deadlock when it tries to cleanup $process
@ -761,7 +768,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testRunProcessWithTimeout()
{
$timeout = 0.5;
$process = $this->getProcess('php -r "usleep(600000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(600000);"');
$process->setTimeout($timeout);
$start = microtime(true);
try {
@ -783,13 +790,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testCheckTimeoutOnNonStartedProcess()
{
$process = $this->getProcess('php -r "sleep(3);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->checkTimeout();
}
public function testCheckTimeoutOnTerminatedProcess()
{
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$process->checkTimeout();
}
@ -798,7 +805,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
{
$timeout = 0.5;
$precision = 100000;
$process = $this->getProcess('php -r "sleep(3);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->setTimeout($timeout);
$start = microtime(true);
@ -820,7 +827,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testIdleTimeout()
{
$process = $this->getProcess('php -r "sleep(3);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->setTimeout(10);
$process->setIdleTimeout(0.5);
@ -837,7 +844,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testIdleTimeoutNotExceededWhenOutputIsSent()
{
$process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
$process->setTimeout(2);
$process->setIdleTimeout(1);
@ -853,7 +860,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testStartAfterATimeout()
{
$process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 1000; while ($n--) {echo \'\'; usleep(1000); }')));
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 1000; while ($n--) {echo \'\'; usleep(1000); }')));
$process->setTimeout(0.1);
try {
@ -868,7 +875,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetPid()
{
$process = $this->getProcess('php -r "usleep(500000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$process->start();
$this->assertGreaterThan(0, $process->getPid());
$process->wait();
@ -876,13 +883,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testGetPidIsNullBeforeStart()
{
$process = $this->getProcess('php -r "sleep(1);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
$this->assertNull($process->getPid());
}
public function testGetPidIsNullAfterRun()
{
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->run();
$this->assertNull($process->getPid());
}
@ -927,7 +934,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testSignalProcessNotRunning()
{
$this->verifyPosixIsEnabled();
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->signal(SIGHUP);
}
@ -936,7 +943,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testMethodsThatNeedARunningProcess($method)
{
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
$process->{$method}();
}
@ -957,7 +964,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testMethodsThatNeedATerminatedProcess($method)
{
$process = $this->getProcess('php -r "sleep(1);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
$process->start();
try {
$process->{$method}();
@ -999,7 +1006,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('POSIX signals do not work on Windows');
}
$process = $this->getProcess('php -r "sleep(3);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->start();
$process->signal(-4);
}
@ -1013,14 +1020,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('POSIX signals do not work on Windows');
}
$process = $this->getProcess('php -r "sleep(3);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->start();
$process->signal('Céphalopodes');
}
public function testDisableOutputDisablesTheOutput()
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$this->assertFalse($p->isOutputDisabled());
$p->disableOutput();
$this->assertTrue($p->isOutputDisabled());
@ -1030,7 +1037,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testDisableOutputWhileRunningThrowsException()
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$p->start();
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Disabling output while the process is running is not possible.');
$p->disableOutput();
@ -1038,7 +1045,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testEnableOutputWhileRunningThrowsException()
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$p->disableOutput();
$p->start();
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Enabling output while the process is running is not possible.');
@ -1047,7 +1054,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$p->disableOutput();
$p->start();
$p->wait();
@ -1083,7 +1090,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testStartWithACallbackAndDisabledOutput($startMethod, $exception, $exceptionMessage)
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$p->disableOutput();
$this->setExpectedException($exception, $exceptionMessage);
$p->{$startMethod}(function () {});
@ -1103,7 +1110,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testGetOutputWhileDisabled($fetchMethod)
{
$p = $this->getProcess('php -r "usleep(500000);"');
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$p->disableOutput();
$p->start();
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Output has been disabled.');

View file

@ -102,7 +102,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Cannot test when open_basedir is set');
}
$this->iniSet('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
$this->iniSet('open_basedir', dirname(PHP_BINARY).(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
$finder = new ExecutableFinder();
$result = $finder->find($this->getPhpBinaryName());
@ -125,7 +125,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
}
$this->setPath('');
$this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
$this->iniSet('open_basedir', PHP_BINARY.(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
$finder = new ExecutableFinder();
$result = $finder->find($this->getPhpBinaryName(), false);

View file

@ -53,10 +53,10 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
$f = new PhpExecutableFinder();
$current = $f->find();
$current = getenv('PHP_BINARY') ?: PHP_BINARY;
$this->assertEquals($f->find(), $current.' --php', '::find() returns the executable PHP');
$this->assertEquals($f->find(false), $current, '::find() returns the executable PHP');
$this->assertEquals($current.' --php', $f->find(), '::find() returns the executable PHP');
$this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
}
/**
@ -91,7 +91,7 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
//TODO maybe php executable is custom or even Windows
if ('\\' === DIRECTORY_SEPARATOR) {
$this->assertTrue(is_executable($current));
$this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes');
$this->assertTrue((bool) preg_match('/'.addslashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes');
}
}
}

View file

@ -32,7 +32,7 @@ while ($read || $write) {
}
$out = (binary) substr($out, $written);
}
if (null === $read && strlen($out) < 1) {
if (null === $read && '' === $out) {
$write = array_diff($write, array(STDOUT));
}
@ -43,7 +43,7 @@ while ($read || $write) {
}
$err = (binary) substr($err, $written);
}
if (null === $read && strlen($err) < 1) {
if (null === $read && '' === $err) {
$write = array_diff($write, array(STDERR));
}

View file

@ -150,7 +150,7 @@ class SimpleProcessTest extends AbstractProcessTest
public function testStopTerminatesProcessCleanly()
{
try {
$process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process->run(function () use ($process) {
$process->stop();
});
@ -164,7 +164,7 @@ class SimpleProcessTest extends AbstractProcessTest
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
try {
$process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process->run(function () use ($process) {
if ($process->isRunning()) {
$process->signal(defined('SIGKILL') ? SIGKILL : 9);
@ -180,7 +180,7 @@ class SimpleProcessTest extends AbstractProcessTest
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
try {
$process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
$process->run(function () use ($process) {
if ($process->isRunning()) {
$process->signal(defined('SIGTERM') ? SIGTERM : 15);