aboutsummaryrefslogtreecommitdiffstats
path: root/library/symfony/process/Tests/SimpleProcessTest.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-01 22:29:51 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-01 22:29:51 -0400
commitc2d15e6c3bd8a29bae89d184a999ddac15fcb807 (patch)
tree96cbbfa98f131d830fbfd154f82e37383bb37bd8 /library/symfony/process/Tests/SimpleProcessTest.php
parentb1ae4d776c7c093c7f3ff6905e1a5302fbd5e3f6 (diff)
downloadvolse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.gz
volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.bz2
volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.zip
New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis
Diffstat (limited to 'library/symfony/process/Tests/SimpleProcessTest.php')
-rw-r--r--library/symfony/process/Tests/SimpleProcessTest.php216
1 files changed, 216 insertions, 0 deletions
diff --git a/library/symfony/process/Tests/SimpleProcessTest.php b/library/symfony/process/Tests/SimpleProcessTest.php
new file mode 100644
index 000000000..78f20eb10
--- /dev/null
+++ b/library/symfony/process/Tests/SimpleProcessTest.php
@@ -0,0 +1,216 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Process\Tests;
+
+use Symfony\Component\Process\Process;
+
+class SimpleProcessTest extends AbstractProcessTest
+{
+ private $enabledSigchild = false;
+
+ protected function setUp()
+ {
+ ob_start();
+ phpinfo(INFO_GENERAL);
+
+ $this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
+ }
+
+ public function testGetExitCode()
+ {
+ $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
+ parent::testGetExitCode();
+ }
+
+ public function testExitCodeCommandFailed()
+ {
+ $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
+ parent::testExitCodeCommandFailed();
+ }
+
+ public function testProcessIsSignaledIfStopped()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
+ parent::testProcessIsSignaledIfStopped();
+ }
+
+ public function testProcessWithTermSignal()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
+ parent::testProcessWithTermSignal();
+ }
+
+ public function testProcessIsNotSignaled()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
+ parent::testProcessIsNotSignaled();
+ }
+
+ public function testProcessWithoutTermSignal()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
+ parent::testProcessWithoutTermSignal();
+ }
+
+ public function testExitCodeText()
+ {
+ $this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
+ parent::testExitCodeText();
+ }
+
+ public function testIsSuccessful()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testIsSuccessful();
+ }
+
+ public function testIsNotSuccessful()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testIsNotSuccessful();
+ }
+
+ public function testGetPid()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testGetPid();
+ }
+
+ public function testGetPidIsNullBeforeStart()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testGetPidIsNullBeforeStart();
+ }
+
+ public function testGetPidIsNullAfterRun()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testGetPidIsNullAfterRun();
+ }
+
+ public function testSignal()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+ parent::testSignal();
+ }
+
+ public function testProcessWithoutTermSignalIsNotSignaled()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
+ parent::testProcessWithoutTermSignalIsNotSignaled();
+ }
+
+ public function testProcessThrowsExceptionWhenExternallySignaled()
+ {
+ $this->skipIfPHPSigchild(); // This test use PID that is not available in this case
+ parent::testProcessThrowsExceptionWhenExternallySignaled();
+ }
+
+ public function testExitCodeIsAvailableAfterSignal()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+ parent::testExitCodeIsAvailableAfterSignal();
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Process\Exception\LogicException
+ * @expectedExceptionMessage Can not send signal on a non running process.
+ */
+ public function testSignalProcessNotRunning()
+ {
+ parent::testSignalProcessNotRunning();
+ }
+
+ public function testSignalWithWrongIntSignal()
+ {
+ if ($this->enabledSigchild) {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+ } else {
+ $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `-4`.');
+ }
+ parent::testSignalWithWrongIntSignal();
+ }
+
+ public function testSignalWithWrongNonIntSignal()
+ {
+ if ($this->enabledSigchild) {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+ } else {
+ $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `Céphalopodes`.');
+ }
+ parent::testSignalWithWrongNonIntSignal();
+ }
+
+ public function testStopTerminatesProcessCleanly()
+ {
+ $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
+ $process->run(function () use ($process) {
+ $process->stop();
+ });
+ $this->assertTrue(true, 'A call to stop() is not expected to cause wait() to throw a RuntimeException');
+ }
+
+ public function testKillSignalTerminatesProcessCleanly()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+
+ $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
+ $process->run(function () use ($process) {
+ if ($process->isRunning()) {
+ $process->signal(defined('SIGKILL') ? SIGKILL : 9);
+ }
+ });
+ $this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
+ }
+
+ public function testTermSignalTerminatesProcessCleanly()
+ {
+ $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
+
+ $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
+ $process->run(function () use ($process) {
+ if ($process->isRunning()) {
+ $process->signal(defined('SIGTERM') ? SIGTERM : 15);
+ }
+ });
+ $this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
+ }
+
+ public function testStopWithTimeoutIsActuallyWorking()
+ {
+ $this->skipIfPHPSigchild();
+
+ parent::testStopWithTimeoutIsActuallyWorking();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
+ {
+ return new Process($commandline, $cwd, $env, $input, $timeout, $options);
+ }
+
+ private function skipIfPHPSigchild()
+ {
+ if ($this->enabledSigchild) {
+ $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
+ }
+ }
+
+ private function expectExceptionIfPHPSigchild($classname, $message)
+ {
+ if ($this->enabledSigchild) {
+ $this->setExpectedException($classname, $message);
+ }
+ }
+}