You are here

class SimpleProcessTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/process/Tests/SimpleProcessTest.php \Symfony\Component\Process\Tests\SimpleProcessTest

Hierarchy

  • class \Symfony\Component\Process\Tests\AbstractProcessTest extends \Symfony\Component\Process\Tests\PHPUnit_Framework_TestCase

Expanded class hierarchy of SimpleProcessTest

File

vendor/symfony/process/Tests/SimpleProcessTest.php, line 16

Namespace

Symfony\Component\Process\Tests
View source
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();
  }
  public function testSignalProcessNotRunning() {
    $this
      ->setExpectedException('Symfony\\Component\\Process\\Exception\\LogicException', 'Can not send signal on a non running process.');
    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() {
    try {
      $process = $this
        ->getProcess(self::$phpBin . ' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
      $process
        ->run(function () use ($process) {
        $process
          ->stop();
      });
    } catch (\RuntimeException $e) {
      $this
        ->fail('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.');
    try {
      $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);
        }
      });
    } catch (\RuntimeException $e) {
      $this
        ->fail('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.');
    try {
      $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);
        }
      });
    } catch (\RuntimeException $e) {
      $this
        ->fail('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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractProcessTest::$phpBin protected static property
AbstractProcessTest::chainedCommandsOutputProvider public function
AbstractProcessTest::methodProvider public function provides default method names for simple getter/setter.
AbstractProcessTest::pipesCodeProvider public function
AbstractProcessTest::provideInputValues public function
AbstractProcessTest::provideInvalidInputValues public function
AbstractProcessTest::provideLegacyInputValues public function
AbstractProcessTest::provideMethodsThatNeedARunningProcess public function
AbstractProcessTest::provideMethodsThatNeedATerminatedProcess public function
AbstractProcessTest::provideOutputFetchingMethods public function
AbstractProcessTest::provideStartMethods public function 1
AbstractProcessTest::responsesCodeProvider public function
AbstractProcessTest::setUpBeforeClass public static function
AbstractProcessTest::testAllOutputIsActuallyReadOnTermination public function
AbstractProcessTest::testCallbackIsExecutedForOutput public function
AbstractProcessTest::testCallbacksAreExecutedWithStart public function
AbstractProcessTest::testChainedCommandsOutput public function @dataProvider chainedCommandsOutputProvider
AbstractProcessTest::testCheckTimeoutOnNonStartedProcess public function
AbstractProcessTest::testCheckTimeoutOnStartedProcess public function 2
AbstractProcessTest::testCheckTimeoutOnTerminatedProcess public function
AbstractProcessTest::testDisableOutputDisablesTheOutput public function
AbstractProcessTest::testDisableOutputWhileIdleTimeoutIsSet public function
AbstractProcessTest::testDisableOutputWhileRunningThrowsException public function
AbstractProcessTest::testEnableOrDisableOutputAfterRunDoesNotThrowException public function
AbstractProcessTest::testEnableOutputWhileRunningThrowsException public function
AbstractProcessTest::testExitCodeTextIsNullWhenExitCodeIsNull public function 1
AbstractProcessTest::testFloatAndNullTimeout public function
AbstractProcessTest::testFlushErrorOutput public function
AbstractProcessTest::testFlushOutput public function
AbstractProcessTest::testGetEmptyIncrementalErrorOutput public function
AbstractProcessTest::testGetEmptyIncrementalOutput public function
AbstractProcessTest::testGetErrorOutput public function
AbstractProcessTest::testGetExitCodeIsNullOnStart public function 1
AbstractProcessTest::testGetExitCodeIsNullOnWhenStartingAgain public function 1
AbstractProcessTest::testGetIncrementalErrorOutput public function
AbstractProcessTest::testGetIncrementalOutput public function
AbstractProcessTest::testGetOutput public function
AbstractProcessTest::testGetOutputWhileDisabled public function @dataProvider provideOutputFetchingMethods
AbstractProcessTest::testIdleTimeout public function
AbstractProcessTest::testIdleTimeoutNotExceededWhenOutputIsSent public function
AbstractProcessTest::testInvalidInput public function @dataProvider provideInvalidInputValues @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException @expectedExceptionMessage Symfony\Component\Process\Process::setInput only accepts strings or stream resources.
AbstractProcessTest::testIsSuccessfulOnlyAfterTerminated public function 1
AbstractProcessTest::testLegacyValidInput public function @dataProvider provideLegacyInputValues @group legacy
AbstractProcessTest::testMethodsThatNeedARunningProcess public function @dataProvider provideMethodsThatNeedARunningProcess
AbstractProcessTest::testMethodsThatNeedATerminatedProcess public function @dataProvider provideMethodsThatNeedATerminatedProcess
AbstractProcessTest::testMustRun public function 1
AbstractProcessTest::testMustRunThrowsException public function @expectedException \Symfony\Component\Process\Exception\ProcessFailedException 1
AbstractProcessTest::testNegativeTimeoutFromConstructor public function @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
AbstractProcessTest::testNegativeTimeoutFromSetter public function @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
AbstractProcessTest::testPhpDeadlock public function
AbstractProcessTest::testProcessPipes public function tests results from sub processes.
AbstractProcessTest::testProcessResponses public function tests results from sub processes.
AbstractProcessTest::testPTYCommand public function
AbstractProcessTest::testRestart public function
AbstractProcessTest::testRunProcessWithTimeout public function 2
AbstractProcessTest::testSetIdleTimeoutWhileOutputIsDisabled public function
AbstractProcessTest::testSetInputWhileRunningThrowsAnException public function
AbstractProcessTest::testSetNullIdleTimeoutWhileOutputIsDisabled public function
AbstractProcessTest::testSetStreamAsInput public function @dataProvider pipesCodeProvider
AbstractProcessTest::testStartAfterATimeout public function 1
AbstractProcessTest::testStartIsNonBlocking public function
AbstractProcessTest::testStartWithACallbackAndDisabledOutput public function @dataProvider provideStartMethods
AbstractProcessTest::testStatus public function
AbstractProcessTest::testStop public function
AbstractProcessTest::testSuccessfulMustRunHasCorrectExitCode public function 1
AbstractProcessTest::testThatProcessDoesNotThrowWarningDuringRun public function
AbstractProcessTest::testTTYCommand public function
AbstractProcessTest::testTTYCommandExitCode public function 1
AbstractProcessTest::testTTYInWindowsEnvironment public function
AbstractProcessTest::testUpdateStatus public function
AbstractProcessTest::testValidInput public function @dataProvider provideInputValues
AbstractProcessTest::testZeroAsOutput public function
AbstractProcessTest::verifyPosixIsEnabled private function
SimpleProcessTest::$enabledSigchild private property
SimpleProcessTest::expectExceptionIfPHPSigchild private function
SimpleProcessTest::getProcess protected function Overrides AbstractProcessTest::getProcess
SimpleProcessTest::setUp protected function
SimpleProcessTest::skipIfPHPSigchild private function
SimpleProcessTest::testExitCodeCommandFailed public function Overrides AbstractProcessTest::testExitCodeCommandFailed
SimpleProcessTest::testExitCodeIsAvailableAfterSignal public function Overrides AbstractProcessTest::testExitCodeIsAvailableAfterSignal
SimpleProcessTest::testExitCodeText public function Overrides AbstractProcessTest::testExitCodeText
SimpleProcessTest::testGetExitCode public function Overrides AbstractProcessTest::testGetExitCode
SimpleProcessTest::testGetPid public function Overrides AbstractProcessTest::testGetPid
SimpleProcessTest::testGetPidIsNullAfterRun public function Overrides AbstractProcessTest::testGetPidIsNullAfterRun
SimpleProcessTest::testGetPidIsNullBeforeStart public function Overrides AbstractProcessTest::testGetPidIsNullBeforeStart
SimpleProcessTest::testIsNotSuccessful public function Overrides AbstractProcessTest::testIsNotSuccessful
SimpleProcessTest::testIsSuccessful public function Overrides AbstractProcessTest::testIsSuccessful
SimpleProcessTest::testKillSignalTerminatesProcessCleanly public function
SimpleProcessTest::testProcessIsNotSignaled public function Overrides AbstractProcessTest::testProcessIsNotSignaled
SimpleProcessTest::testProcessIsSignaledIfStopped public function Overrides AbstractProcessTest::testProcessIsSignaledIfStopped
SimpleProcessTest::testProcessThrowsExceptionWhenExternallySignaled public function Overrides AbstractProcessTest::testProcessThrowsExceptionWhenExternallySignaled
SimpleProcessTest::testProcessWithoutTermSignal public function Overrides AbstractProcessTest::testProcessWithoutTermSignal
SimpleProcessTest::testProcessWithoutTermSignalIsNotSignaled public function Overrides AbstractProcessTest::testProcessWithoutTermSignalIsNotSignaled
SimpleProcessTest::testProcessWithTermSignal public function Overrides AbstractProcessTest::testProcessWithTermSignal
SimpleProcessTest::testSignal public function Overrides AbstractProcessTest::testSignal
SimpleProcessTest::testSignalProcessNotRunning public function @expectedException \Symfony\Component\Process\Exception\LogicException Overrides AbstractProcessTest::testSignalProcessNotRunning
SimpleProcessTest::testSignalWithWrongIntSignal public function @expectedException \Symfony\Component\Process\Exception\RuntimeException Overrides AbstractProcessTest::testSignalWithWrongIntSignal
SimpleProcessTest::testSignalWithWrongNonIntSignal public function @expectedException \Symfony\Component\Process\Exception\RuntimeException Overrides AbstractProcessTest::testSignalWithWrongNonIntSignal
SimpleProcessTest::testStopTerminatesProcessCleanly public function
SimpleProcessTest::testStopWithTimeoutIsActuallyWorking public function Overrides AbstractProcessTest::testStopWithTimeoutIsActuallyWorking
SimpleProcessTest::testTermSignalTerminatesProcessCleanly public function