[Process] Add unit tests for #7865

This commit is contained in:
Romain Neutron 2013-04-29 12:07:05 +02:00
parent 84d759d3d5
commit 421c354ac9
3 changed files with 31 additions and 1 deletions

View File

@ -337,6 +337,26 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($termSignal, $process->getTermSignal());
}
public function testProcessThrowsExceptionWhenExternallySignaled()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Windows does not support POSIX signals');
}
if (!function_exists('posix_kill')) {
$this->markTestSkipped('posix_kill is required for this test');
}
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
$process = $this->getProcess('exec php -r "while (true) {}"');
$process->start();
posix_kill($process->getPid(), $termSignal);
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'The process stopped because of a "9" signal.');
$process->wait();
}
public function testRestart()
{
$process1 = $this->getProcess('php -r "echo getmypid();"');

View File

@ -133,6 +133,11 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
$this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
}
public function testProcessThrowsExceptionWhenExternallySignaled()
{
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
}
/**
* {@inheritdoc}
*/

View File

@ -84,7 +84,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
{
parent::testSignal();
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
*/
@ -93,6 +93,11 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
parent::testProcessWithoutTermSignalIsNotSignaled();
}
public function testProcessThrowsExceptionWhenExternallySignaled()
{
$this->markTestSkipped('Retrieving Pid is not supported in sigchild environment');
}
/**
* {@inheritdoc}
*/