4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Process\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Process\PhpExecutableFinder;
18 * @author Robert Schönthal <seroscho@googlemail.com>
20 class PhpExecutableFinderTest extends TestCase
23 * tests find() with the constant PHP_BINARY.
25 public function testFind()
27 if (\defined('HHVM_VERSION')) {
28 $this->markTestSkipped('Should not be executed in HHVM context.');
31 $f = new PhpExecutableFinder();
33 $current = PHP_BINARY;
34 $args = 'phpdbg' === \PHP_SAPI ? ' -qrr' : '';
36 $this->assertEquals($current.$args, $f->find(), '::find() returns the executable PHP');
37 $this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
41 * tests find() with the env var / constant PHP_BINARY with HHVM.
43 public function testFindWithHHVM()
45 if (!\defined('HHVM_VERSION')) {
46 $this->markTestSkipped('Should be executed in HHVM context.');
49 $f = new PhpExecutableFinder();
51 $current = getenv('PHP_BINARY') ?: PHP_BINARY;
53 $this->assertEquals($current.' --php', $f->find(), '::find() returns the executable PHP');
54 $this->assertEquals($current, $f->find(false), '::find() returns the executable PHP');
58 * tests find() with the env var PHP_PATH.
60 public function testFindArguments()
62 $f = new PhpExecutableFinder();
64 if (\defined('HHVM_VERSION')) {
65 $this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments');
66 } elseif ('phpdbg' === \PHP_SAPI) {
67 $this->assertEquals($f->findArguments(), array('-qrr'), '::findArguments() returns phpdbg arguments');
69 $this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');