From 23fc32f78fe5587850e4b0fdc84d59ae6f357db7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 10 Oct 2015 18:01:13 +0200 Subject: [PATCH] [Process] Don't use @requires on abstract class --- .../Process/Tests/AbstractProcessTest.php | 33 +++++++++++-------- .../Process/Tests/SimpleProcessTest.php | 5 ++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index d46ebe2501..62616eed34 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -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); } diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index 8203d8da3e..a52cd437a8 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -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(); }