PhpExecutableFinderTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\PhpExecutableFinder;
  12. /**
  13. * @author Robert Schönthal <seroscho@googlemail.com>
  14. */
  15. class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
  16. {
  17. /**
  18. * tests find() with the constant PHP_BINARY.
  19. */
  20. public function testFind()
  21. {
  22. if (defined('HHVM_VERSION')) {
  23. $this->markTestSkipped('Should not be executed in HHVM context.');
  24. }
  25. $f = new PhpExecutableFinder();
  26. $current = PHP_BINARY;
  27. $args = 'phpdbg' === PHP_SAPI ? ' -qrr' : '';
  28. $this->assertEquals($current.$args, $f->find(), '::find() returns the executable PHP');
  29. $this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
  30. }
  31. /**
  32. * tests find() with the env var / constant PHP_BINARY with HHVM.
  33. */
  34. public function testFindWithHHVM()
  35. {
  36. if (!defined('HHVM_VERSION')) {
  37. $this->markTestSkipped('Should be executed in HHVM context.');
  38. }
  39. $f = new PhpExecutableFinder();
  40. $current = getenv('PHP_BINARY') ?: PHP_BINARY;
  41. $this->assertEquals($current.' --php', $f->find(), '::find() returns the executable PHP');
  42. $this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
  43. }
  44. /**
  45. * tests find() with the env var PHP_PATH.
  46. */
  47. public function testFindArguments()
  48. {
  49. $f = new PhpExecutableFinder();
  50. if (defined('HHVM_VERSION')) {
  51. $this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments');
  52. } elseif ('phpdbg' === PHP_SAPI) {
  53. $this->assertEquals($f->findArguments(), array('-qrr'), '::findArguments() returns phpdbg arguments');
  54. } else {
  55. $this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');
  56. }
  57. }
  58. }