SimpleProcessTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Process\Tests;
  11. use Symfony\Component\Process\Process;
  12. class SimpleProcessTest extends AbstractProcessTest
  13. {
  14. private $enabledSigchild = false;
  15. public function setUp()
  16. {
  17. ob_start();
  18. phpinfo(INFO_GENERAL);
  19. $this->enabledSigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  20. }
  21. public function testGetExitCode()
  22. {
  23. $this->skipIfPHPSigchild();
  24. parent::testGetExitCode();
  25. }
  26. public function testExitCodeCommandFailed()
  27. {
  28. $this->skipIfPHPSigchild();
  29. parent::testExitCodeCommandFailed();
  30. }
  31. public function testProcessIsSignaledIfStopped()
  32. {
  33. $this->skipIfPHPSigchild();
  34. parent::testProcessIsSignaledIfStopped();
  35. }
  36. public function testProcessWithTermSignal()
  37. {
  38. $this->skipIfPHPSigchild();
  39. parent::testProcessWithTermSignal();
  40. }
  41. public function testProcessIsNotSignaled()
  42. {
  43. $this->skipIfPHPSigchild();
  44. parent::testProcessIsNotSignaled();
  45. }
  46. public function testProcessWithoutTermSignal()
  47. {
  48. $this->skipIfPHPSigchild();
  49. parent::testProcessWithoutTermSignal();
  50. }
  51. public function testExitCodeText()
  52. {
  53. $this->skipIfPHPSigchild();
  54. parent::testExitCodeText();
  55. }
  56. public function testIsSuccessful()
  57. {
  58. $this->skipIfPHPSigchild();
  59. parent::testIsSuccessful();
  60. }
  61. public function testIsNotSuccessful()
  62. {
  63. $this->skipIfPHPSigchild();
  64. parent::testIsNotSuccessful();
  65. }
  66. public function testGetPid()
  67. {
  68. $this->skipIfPHPSigchild();
  69. parent::testGetPid();
  70. }
  71. public function testGetPidIsNullBeforeStart()
  72. {
  73. $this->skipIfPHPSigchild();
  74. parent::testGetPidIsNullBeforeStart();
  75. }
  76. public function testGetPidIsNullAfterRun()
  77. {
  78. $this->skipIfPHPSigchild();
  79. parent::testGetPidIsNullAfterRun();
  80. }
  81. public function testSignal()
  82. {
  83. $this->skipIfPHPSigchild();
  84. parent::testSignal();
  85. }
  86. /**
  87. * @expectedException Symfony\Component\Process\Exception\LogicException
  88. */
  89. public function testSignalProcessNotRunning()
  90. {
  91. $this->skipIfPHPSigchild();
  92. parent::testSignalProcessNotRunning();
  93. }
  94. /**
  95. * @expectedException Symfony\Component\Process\Exception\RuntimeException
  96. */
  97. public function testSignalWithWrongIntSignal()
  98. {
  99. $this->skipIfPHPSigchild();
  100. parent::testSignalWithWrongIntSignal();
  101. }
  102. /**
  103. * @expectedException Symfony\Component\Process\Exception\RuntimeException
  104. */
  105. public function testSignalWithWrongNonIntSignal()
  106. {
  107. $this->skipIfPHPSigchild();
  108. parent::testSignalWithWrongNonIntSignal();
  109. }
  110. /**
  111. * {@inheritdoc}
  112. */
  113. protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array())
  114. {
  115. return new Process($commandline, $cwd, $env, $stdin, $timeout, $options);
  116. }
  117. private function skipIfPHPSigchild()
  118. {
  119. if ($this->enabledSigchild) {
  120. $this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
  121. }
  122. }
  123. }