Add ability to specify project sub-path and set flag for code coverage

This commit is contained in:
Stephen Brooks 2013-09-18 09:53:01 +01:00
parent 463ac8a6ee
commit 9b4c35a11e

18
PHPCI/Plugin/PhpUnit.php Normal file → Executable file
View file

@ -30,6 +30,14 @@ class PhpUnit implements \PHPCI\Plugin
*/
protected $runFrom;
/**
* @var string, in cases where tests files are in a sub path of the /tests path,
* allows this path to be set in the config.
*/
protected $path;
protected $coverage = "";
/**
* @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit
*/
@ -54,6 +62,14 @@ class PhpUnit implements \PHPCI\Plugin
if (isset($options['args'])) {
$this->args = $options['args'];
}
if (isset($options['path'])) {
$this->path = $options['path'];
}
if (isset($options['coverage'])) {
$this->coverage = " --coverage-html {$options['coverage']} ";
}
}
/**
@ -86,7 +102,7 @@ class PhpUnit implements \PHPCI\Plugin
chdir($this->phpci->buildPath.'/'.$this->runFrom);
}
$cmd = PHPCI_BIN_DIR . 'phpunit %s -c "%s"';
$cmd = PHPCI_BIN_DIR . 'phpunit %s -c "%s" ' . $this->coverage . $this->path;
$success = $this->phpci->executeCommand($cmd, $this->args, $this->phpci->buildPath . $configPath);
if ($this->runFrom) {