minor #16192 [Process] Don't use @requires on abstract class (nicolas-grekas)
This PR was merged into the 2.3 branch.
Discussion
----------
[Process] Don't use @requires on abstract class
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
23fc32f
[Process] Don't use @requires on abstract class
This commit is contained in:
commit
803ff9faf3
@ -71,11 +71,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($p->getTimeout());
|
$this->assertNull($p->getTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires extension pcntl
|
|
||||||
*/
|
|
||||||
public function testStopWithTimeoutIsActuallyWorking()
|
public function testStopWithTimeoutIsActuallyWorking()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('pcntl')) {
|
||||||
|
$this->markTestSkipped('Extension pcntl is required.');
|
||||||
|
}
|
||||||
|
|
||||||
// exec is mandatory here since we send a signal to the process
|
// exec is mandatory here since we send a signal to the process
|
||||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||||
// command with exec
|
// command with exec
|
||||||
@ -624,11 +625,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($termSignal, $process->getTermSignal());
|
$this->assertEquals($termSignal, $process->getTermSignal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires function posix_kill
|
|
||||||
*/
|
|
||||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||||
{
|
{
|
||||||
|
if (!function_exists('posix_kill')) {
|
||||||
|
$this->markTestSkipped('Function posix_kill is required.');
|
||||||
|
}
|
||||||
|
|
||||||
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
||||||
|
|
||||||
$process = $this->getProcess('exec php -r "while (true) {}"');
|
$process = $this->getProcess('exec php -r "while (true) {}"');
|
||||||
@ -764,11 +766,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($process->getPid());
|
$this->assertNull($process->getPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires extension pcntl
|
|
||||||
*/
|
|
||||||
public function testSignal()
|
public function testSignal()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('pcntl')) {
|
||||||
|
$this->markTestSkipped('Extension pcntl is required.');
|
||||||
|
}
|
||||||
|
|
||||||
$process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php');
|
$process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php');
|
||||||
$process->start();
|
$process->start();
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
@ -781,11 +784,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
|
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires extension pcntl
|
|
||||||
*/
|
|
||||||
public function testExitCodeIsAvailableAfterSignal()
|
public function testExitCodeIsAvailableAfterSignal()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('pcntl')) {
|
||||||
|
$this->markTestSkipped('Extension pcntl is required.');
|
||||||
|
}
|
||||||
|
|
||||||
$process = $this->getProcess('sleep 4');
|
$process = $this->getProcess('sleep 4');
|
||||||
$process->start();
|
$process->start();
|
||||||
$process->signal(SIGKILL);
|
$process->signal(SIGKILL);
|
||||||
@ -802,10 +806,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||||
* @requires extension pcntl
|
|
||||||
*/
|
*/
|
||||||
public function testSignalProcessNotRunning()
|
public function testSignalProcessNotRunning()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('pcntl')) {
|
||||||
|
$this->markTestSkipped('Extension pcntl is required.');
|
||||||
|
}
|
||||||
|
|
||||||
$process = $this->getProcess(self::$phpBin.' -v');
|
$process = $this->getProcess(self::$phpBin.' -v');
|
||||||
$process->signal(SIGHUP);
|
$process->signal(SIGHUP);
|
||||||
}
|
}
|
||||||
|
@ -121,9 +121,12 @@ class SimpleProcessTest extends AbstractProcessTest
|
|||||||
parent::testExitCodeIsAvailableAfterSignal();
|
parent::testExitCodeIsAvailableAfterSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||||
|
* @expectedExceptionMessage Can not send signal on a non running process.
|
||||||
|
*/
|
||||||
public function testSignalProcessNotRunning()
|
public function testSignalProcessNotRunning()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.');
|
|
||||||
parent::testSignalProcessNotRunning();
|
parent::testSignalProcessNotRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user