composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -55,13 +55,13 @@ class ProcessTest extends TestCase
{
try {
// Check that it works fine if the CWD exists
$cmd = new Process('echo test', __DIR__);
$cmd = new Process(array('echo', 'test'), __DIR__);
$cmd->run();
} catch (\Exception $e) {
$this->fail($e);
}
$cmd = new Process('echo test', __DIR__.'/notfound/');
$cmd = new Process(array('echo', 'test'), __DIR__.'/notfound/');
$cmd->run();
}
@@ -133,6 +133,30 @@ class ProcessTest extends TestCase
$this->assertLessThan(15, microtime(true) - $start);
}
public function testWaitUntilSpecificOutput()
{
$p = $this->getProcess(array(self::$phpBin, __DIR__.'/KillableProcessWithOutput.php'));
$p->start();
$start = microtime(true);
$completeOutput = '';
$result = $p->waitUntil(function ($type, $output) use (&$completeOutput) {
return false !== strpos($completeOutput .= $output, 'One more');
});
$this->assertTrue($result);
$this->assertLessThan(20, microtime(true) - $start);
$this->assertStringStartsWith("First iteration output\nSecond iteration output\nOne more", $completeOutput);
$p->stop();
}
public function testWaitUntilCanReturnFalse()
{
$p = $this->getProcess('echo foo');
$p->start();
$this->assertFalse($p->waitUntil(function () { return false; }));
}
public function testAllOutputIsActuallyReadOnTermination()
{
// this code will result in a maximum of 2 reads of 8192 bytes by calling
@@ -1436,12 +1460,12 @@ class ProcessTest extends TestCase
$p = new Process(array(self::$phpBin, '-r', 'echo $argv[1];', $arg));
$p->run();
$this->assertSame($arg, $p->getOutput());
$this->assertSame((string) $arg, $p->getOutput());
}
public function testRawCommandLine()
{
$p = new Process(sprintf('"%s" -r %s "a" "" "b"', self::$phpBin, escapeshellarg('print_r($argv);')));
$p = Process::fromShellCommandline(sprintf('"%s" -r %s "a" "" "b"', self::$phpBin, escapeshellarg('print_r($argv);')));
$p->run();
$expected = <<<EOTXT
@@ -1466,32 +1490,29 @@ EOTXT;
yield array("a!b\tc");
yield array('a\\\\"\\"');
yield array('éÉèÈàÀöä');
yield array(null);
yield array(1);
yield array(1.1);
}
public function testEnvArgument()
{
$env = array('FOO' => 'Foo', 'BAR' => 'Bar');
$cmd = '\\' === \DIRECTORY_SEPARATOR ? 'echo !FOO! !BAR! !BAZ!' : 'echo $FOO $BAR $BAZ';
$p = new Process($cmd, null, $env);
$p = Process::fromShellCommandline($cmd, null, $env);
$p->run(null, array('BAR' => 'baR', 'BAZ' => 'baZ'));
$this->assertSame('Foo baR baZ', rtrim($p->getOutput()));
$this->assertSame($env, $p->getEnv());
}
/**
* @param string $commandline
* @param null|string $cwd
* @param null|array $env
* @param null|string $input
* @param int $timeout
* @param array $options
*
* @return Process
*/
private function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60)
private function getProcess($commandline, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process
{
$process = new Process($commandline, $cwd, $env, $input, $timeout);
if (\is_string($commandline)) {
$process = Process::fromShellCommandline($commandline, $cwd, $env, $input, $timeout);
} else {
$process = new Process($commandline, $cwd, $env, $input, $timeout);
}
$process->inheritEnvironmentVariables();
if (self::$process) {
@@ -1501,10 +1522,7 @@ EOTXT;
return self::$process = $process;
}
/**
* @return Process
*/
private function getProcessForCode($code, $cwd = null, array $env = null, $input = null, $timeout = 60)
private function getProcessForCode(string $code, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process
{
return $this->getProcess(array(self::$phpBin, '-r', $code), $cwd, $env, $input, $timeout);
}