[Process] Fix tests on windows
This commit is contained in:
parent
08e95dbbf4
commit
ae1624fe02
@ -136,19 +136,19 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); $n = 0; while ($n < 3) { echo $a; $n++; }')));
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->run();
|
||||
$this->assertEquals(3, preg_match_all('/PHP Notice/', $p->getErrorOutput(), $matches));
|
||||
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
|
||||
}
|
||||
|
||||
public function testGetIncrementalErrorOutput()
|
||||
{
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); usleep(50000); $n = 0; while ($n < 3) { echo $a; $n++; }')));
|
||||
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
|
||||
|
||||
$p->start();
|
||||
while ($p->isRunning()) {
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/PHP Notice/', $p->getIncrementalOutput(), $matches));
|
||||
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
@ -431,6 +431,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php');
|
||||
$process->start();
|
||||
usleep(500000);
|
||||
@ -448,6 +452,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -m');
|
||||
$process->signal(SIGHUP);
|
||||
}
|
||||
@ -457,6 +465,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal(-4);
|
||||
@ -467,6 +479,10 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal('Céphalopodes');
|
||||
|
@ -122,10 +122,18 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$pb->setPrefix('/usr/bin/php');
|
||||
|
||||
$proc = $pb->setArguments(array('-v'))->getProcess();
|
||||
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
|
||||
}
|
||||
|
||||
$proc = $pb->setArguments(array('-i'))->getProcess();
|
||||
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldEscapeArguments()
|
||||
@ -167,7 +175,11 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
->setPrefix('/usr/bin/php')
|
||||
->getProcess();
|
||||
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
|
||||
public function testShouldNotThrowALogicExceptionIfNoPrefix()
|
||||
@ -175,6 +187,10 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$process = ProcessBuilder::create(array('/usr/bin/php'))
|
||||
->getProcess();
|
||||
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
|
||||
} else {
|
||||
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user