Added argument to Phpunit plugin: config. This takes the path to an xml configuration file which will be run instead of the specified directory.

This commit is contained in:
meadsteve 2013-05-15 13:01:47 +01:00
parent c9b17e3534
commit a0528d2cc4

View file

@ -8,19 +8,30 @@ class PhpUnit implements \PHPCI\Plugin
protected $args; protected $args;
protected $phpci; protected $phpci;
/**
* @var string $xmlConfigFile The path of an xml config for PHPUnit
*/
protected $xmlConfigFile;
public function __construct(\PHPCI\Builder $phpci, array $options = array()) public function __construct(\PHPCI\Builder $phpci, array $options = array())
{ {
$this->phpci = $phpci; $this->phpci = $phpci;
$this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath;
$this->xmlConfigFile = isset($options['config']) ? $options['config'] : null;
$this->args = isset($options['args']) ? $options['args'] : ''; $this->args = isset($options['args']) ? $options['args'] : '';
} }
public function execute() public function execute()
{ {
$curdir = getcwd(); if ($this->xmlConfigFile === null) {
chdir($this->phpci->buildPath); $curdir = getcwd();
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory); chdir($this->phpci->buildPath);
chdir($curdir); $success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory);
chdir($curdir);
}
else {
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $this->xmlConfigFile );
}
return $success; return $success;
} }