Merge branch 'php-unit-xml-config'
Conflicts: PHPCI/Plugin/PhpUnit.php
This commit is contained in:
commit
9c0c28a67f
|
@ -16,23 +16,61 @@ class PhpUnit implements \PHPCI\Plugin
|
||||||
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'] : null;
|
||||||
$this->xmlConfigFile = isset($options['config']) ? $options['config'] : null;
|
$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()
|
||||||
{
|
{
|
||||||
if ($this->xmlConfigFile === null) {
|
$success = true;
|
||||||
$curdir = getcwd();
|
|
||||||
chdir($this->phpci->buildPath);
|
// Run any config files first. This can be either a single value or an array.
|
||||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory);
|
if ($this->xmlConfigFile !== null)
|
||||||
chdir($curdir);
|
{
|
||||||
|
$success &= $this->runConfigFile($this->xmlConfigFile);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $this->xmlConfigFile );
|
// Run any dirs next. Again this can be either a single value or an array.
|
||||||
|
if ($this->directory !== null)
|
||||||
|
{
|
||||||
|
$success &= $this->runDir($this->directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function runConfigFile($configPath)
|
||||||
|
{
|
||||||
|
if (is_array($configPath))
|
||||||
|
{
|
||||||
|
return $this->recurseArg($configPath, array($this, "runConfigFile"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $configPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function runDir($dirPath)
|
||||||
|
{
|
||||||
|
if (is_array($dirPath)) {
|
||||||
|
return $this->recurseArg($dirPath, array($this, "runConfigFile"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$curdir = getcwd();
|
||||||
|
chdir($this->phpci->buildPath);
|
||||||
|
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $dirPath);
|
||||||
|
chdir($curdir);
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recurseArg($array, $callable) {
|
||||||
|
$success = true;
|
||||||
|
foreach($array as $subItem) {
|
||||||
|
$success &= call_user_func($callable, $subItem);
|
||||||
|
}
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -83,7 +83,11 @@ Similar to Travis CI, to support PHPCI in your project, you simply need to add a
|
||||||
|
|
||||||
test:
|
test:
|
||||||
php_unit:
|
php_unit:
|
||||||
directory: "tests/"
|
config:
|
||||||
|
- "PHPUnit-all.xml"
|
||||||
|
- "PHPUnit-ubuntu-fix.xml"
|
||||||
|
directory:
|
||||||
|
- "tests/"
|
||||||
php_mess_detector:
|
php_mess_detector:
|
||||||
allow_failures: true
|
allow_failures: true
|
||||||
php_code_sniffer:
|
php_code_sniffer:
|
||||||
|
|
Loading…
Reference in a new issue