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:
Nicolas Grekas 2015-10-10 18:09:26 +02:00
commit 803ff9faf3
2 changed files with 24 additions and 14 deletions

View File

@ -71,11 +71,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertNull($p->getTimeout());
}
/**
* @requires extension pcntl
*/
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
// see https://github.com/symfony/symfony/issues/5030 about prepending
// command with exec
@ -624,11 +625,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($termSignal, $process->getTermSignal());
}
/**
* @requires function posix_kill
*/
public function testProcessThrowsExceptionWhenExternallySignaled()
{
if (!function_exists('posix_kill')) {
$this->markTestSkipped('Function posix_kill is required.');
}
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
$process = $this->getProcess('exec php -r "while (true) {}"');
@ -764,11 +766,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertNull($process->getPid());
}
/**
* @requires extension pcntl
*/
public function testSignal()
{
if (!extension_loaded('pcntl')) {
$this->markTestSkipped('Extension pcntl is required.');
}
$process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php');
$process->start();
usleep(500000);
@ -781,11 +784,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
}
/**
* @requires extension pcntl
*/
public function testExitCodeIsAvailableAfterSignal()
{
if (!extension_loaded('pcntl')) {
$this->markTestSkipped('Extension pcntl is required.');
}
$process = $this->getProcess('sleep 4');
$process->start();
$process->signal(SIGKILL);
@ -802,10 +806,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Process\Exception\LogicException
* @requires extension pcntl
*/
public function testSignalProcessNotRunning()
{
if (!extension_loaded('pcntl')) {
$this->markTestSkipped('Extension pcntl is required.');
}
$process = $this->getProcess(self::$phpBin.' -v');
$process->signal(SIGHUP);
}

View File

@ -121,9 +121,12 @@ class SimpleProcessTest extends AbstractProcessTest
parent::testExitCodeIsAvailableAfterSignal();
}
/**
* @expectedException \Symfony\Component\Process\Exception\LogicException
* @expectedExceptionMessage Can not send signal on a non running process.
*/
public function testSignalProcessNotRunning()
{
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.');
parent::testSignalProcessNotRunning();
}