[Process] fix using argument $php of new PhpProcess()
This commit is contained in:
parent
33b881b9b7
commit
aa6e5851f1
@ -33,11 +33,10 @@ class PhpProcess extends Process
|
|||||||
*/
|
*/
|
||||||
public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
|
public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
|
||||||
{
|
{
|
||||||
|
if (null === $php) {
|
||||||
$executableFinder = new PhpExecutableFinder();
|
$executableFinder = new PhpExecutableFinder();
|
||||||
if (false === $php = $php ?? $executableFinder->find(false)) {
|
$php = $executableFinder->find(false);
|
||||||
$php = null;
|
$php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
|
||||||
} else {
|
|
||||||
$php = array_merge([$php], $executableFinder->findArguments());
|
|
||||||
}
|
}
|
||||||
if ('phpdbg' === \PHP_SAPI) {
|
if ('phpdbg' === \PHP_SAPI) {
|
||||||
$file = tempnam(sys_get_temp_dir(), 'dbg');
|
$file = tempnam(sys_get_temp_dir(), 'dbg');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Process\Tests;
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
use Symfony\Component\Process\PhpProcess;
|
use Symfony\Component\Process\PhpProcess;
|
||||||
|
|
||||||
class PhpProcessTest extends TestCase
|
class PhpProcessTest extends TestCase
|
||||||
@ -45,4 +46,18 @@ PHP
|
|||||||
|
|
||||||
$this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput());
|
$this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPassingPhpExplicitly()
|
||||||
|
{
|
||||||
|
$finder = new PhpExecutableFinder();
|
||||||
|
$php = array_merge([$finder->find(false)], $finder->findArguments());
|
||||||
|
|
||||||
|
$expected = 'hello world!';
|
||||||
|
$script = <<<PHP
|
||||||
|
<?php echo '$expected';
|
||||||
|
PHP;
|
||||||
|
$process = new PhpProcess($script, null, null, 60, $php);
|
||||||
|
$process->run();
|
||||||
|
$this->assertEquals($expected, $process->getOutput());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user