merged branch romainneutron/termsig-tests (PR #7874)
This PR was merged into the master branch.
Discussion
----------
[Process] Add unit tests for #7865
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | |no
| Tests pass? | yes when 2.1 will be merged in master
| License | MIT
This PR adds test for #7865. It's currently failing, but will pass once 2.1 will be merged in master.
Commits
-------
421c354
[Process] Add unit tests for #7865
This commit is contained in:
commit
9869b3af88
|
@ -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();"');
|
||||
|
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
@ -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}
|
||||
*/
|
||||
|
|
Reference in New Issue