PhpExecutableFinderTest.php 2.1 KB

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