From cfe1522e963fc2fcb3c6a1d495a3f539999ddd9f Mon Sep 17 00:00:00 2001 From: Matej Date: Fri, 21 Jun 2019 14:05:19 +0200 Subject: [PATCH] PhpUnit - PHP interpreter as optional parameter --- src/commands/PhpUnit.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/commands/PhpUnit.php b/src/commands/PhpUnit.php index 2edf6b7..5ddc5b7 100644 --- a/src/commands/PhpUnit.php +++ b/src/commands/PhpUnit.php @@ -16,6 +16,8 @@ class PhpUnit extends Command private $options; + private $phpInterpreter; + /** * Returns working directory. System will switch to this directory before running tests @@ -46,6 +48,23 @@ public function getTarget() return $this->target; } + /** + * Returns PHP interpreter. + * @return string + */ + public function getPhpInterpreter() + { + return $this->phpInterpreter ?: 'php'; + } + + /** + * Sets PHP interpreter in your system (e.g. php, php5.6, php7.0...). + * @return string + */ + public function setPhpInterpreter($phpInterpreter) + { + $this->phpInterpreter = $phpInterpreter; + } /** * Sets target to be executed. Dir in working directory, dot (current dir), TestFile, etc @@ -90,7 +109,7 @@ public function execute() if (!is_file($this->options['xdebugExtensionFile'])) { // PHP is quite when extension file does not exists $this->error("Xdebug extension file '{$this->options['xdebugExtensionFile']}' does not exists."); } - $cmd .= 'php -d zend_extension=' . escapeshellarg($this->options['xdebugExtensionFile']) . ' '; + $cmd .= $this->getPhpInterpreter() . ' -d zend_extension=' . escapeshellarg($this->options['xdebugExtensionFile']) . ' '; } $cmd .= escapeshellarg($this->options['executable']) . ' '; $cmd .= escapeshellarg($this->target) . ' ';