PhpCommand: Accept phpunit path as option and fix coverage
This commit is contained in:
parent
776e0803fa
commit
58673b0b95
|
@ -28,6 +28,7 @@ class PhpCommand extends Command
|
||||||
* --verbose Be more verbose.
|
* --verbose Be more verbose.
|
||||||
* --build Enable reporting.
|
* --build Enable reporting.
|
||||||
* --include Pattern to use for including files/test cases.
|
* --include Pattern to use for including files/test cases.
|
||||||
|
* --phpunit Path to the phpunit executable
|
||||||
*
|
*
|
||||||
* EXAMPLES
|
* EXAMPLES
|
||||||
*
|
*
|
||||||
|
@ -42,10 +43,14 @@ class PhpCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function unitAction()
|
public function unitAction()
|
||||||
{
|
{
|
||||||
$build = $this->params->shift('build');
|
$build = (bool) $this->params->shift('build', false);
|
||||||
$include = $this->params->shift('include');
|
$include = $this->params->shift('include');
|
||||||
|
$phpUnit = $this->params->shift('phpunit');
|
||||||
|
|
||||||
|
if (! $phpUnit) {
|
||||||
$phpUnit = exec('which phpunit');
|
$phpUnit = exec('which phpunit');
|
||||||
|
}
|
||||||
|
|
||||||
if (! file_exists($phpUnit)) {
|
if (! file_exists($phpUnit)) {
|
||||||
$this->fail('PHPUnit not found. Please install PHPUnit to be able to run the unit-test suites.');
|
$this->fail('PHPUnit not found. Please install PHPUnit to be able to run the unit-test suites.');
|
||||||
}
|
}
|
||||||
|
@ -75,7 +80,7 @@ class PhpCommand extends Command
|
||||||
$temp->create('phpunit.xml', $phpunitXml->saveXML());
|
$temp->create('phpunit.xml', $phpunitXml->saveXML());
|
||||||
|
|
||||||
chdir($baseDir);
|
chdir($baseDir);
|
||||||
$command = $this->getEnvironmentVariables()
|
$command = $this->getEnvironmentVariables($build)
|
||||||
. $phpUnit
|
. $phpUnit
|
||||||
. " -c {$temp->resolvePath('phpunit.xml')}"
|
. " -c {$temp->resolvePath('phpunit.xml')}"
|
||||||
. ' ' . join(' ', array_merge($options, $this->params->getAllStandalone()));
|
. ' ' . join(' ', array_merge($options, $this->params->getAllStandalone()));
|
||||||
|
@ -182,7 +187,7 @@ class PhpCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Setup some required environment variables
|
* Setup some required environment variables
|
||||||
*/
|
*/
|
||||||
protected function getEnvironmentVariables()
|
protected function getEnvironmentVariables(bool $build)
|
||||||
{
|
{
|
||||||
$modulePaths = [];
|
$modulePaths = [];
|
||||||
foreach (Icinga::app()->getModuleManager()->getModuleInfo() as $module) {
|
foreach (Icinga::app()->getModuleManager()->getModuleInfo() as $module) {
|
||||||
|
@ -202,6 +207,10 @@ class PhpCommand extends Command
|
||||||
implode(PATH_SEPARATOR, $this->app->getModuleManager()->getModuleDirs())
|
implode(PATH_SEPARATOR, $this->app->getModuleManager()->getModuleDirs())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($build) {
|
||||||
|
$vars[] = 'XDEBUG_MODE=coverage';
|
||||||
|
}
|
||||||
|
|
||||||
return join(' ', $vars) . ' ';
|
return join(' ', $vars) . ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue