From 1b93921cd012c8b3797ae7f17186377ff7022fdd Mon Sep 17 00:00:00 2001 From: meadsteve Date: Wed, 15 May 2013 13:01:47 +0100 Subject: [PATCH 1/2] Added argument to Phpunit plugin: config. This takes the path to an xml configuration file which will be run instead of the specified directory. --- PHPCI/Plugin/PhpUnit.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index 34817f11..682521e4 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -8,19 +8,30 @@ class PhpUnit implements \PHPCI\Plugin protected $args; protected $phpci; +/** + * @var string $xmlConfigFile The path of an xml config for PHPUnit + */ + protected $xmlConfigFile; + public function __construct(\PHPCI\Builder $phpci, array $options = array()) { $this->phpci = $phpci; $this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath; + $this->xmlConfigFile = isset($options['config']) ? $options['config'] : null; $this->args = isset($options['args']) ? $options['args'] : ''; } public function execute() { - $curdir = getcwd(); - chdir($this->phpci->buildPath); - $success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $this->directory); - chdir($curdir); + if ($this->xmlConfigFile === null) { + $curdir = getcwd(); + chdir($this->phpci->buildPath); + $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; } From 83f857095d4bbfdf955e78bc92ae1e47e1e75f7d Mon Sep 17 00:00:00 2001 From: meadsteve Date: Thu, 16 May 2013 09:54:15 +0100 Subject: [PATCH 2/2] Updated the comments in the PHPUnit plugin to relfect the fact that directory and config file can also be arrays of strings. --- PHPCI/Plugin/PhpUnit.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index 1ed744fc..fbce90db 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -4,9 +4,13 @@ namespace PHPCI\Plugin; class PhpUnit implements \PHPCI\Plugin { - protected $directory; protected $args; protected $phpci; + + /** + * @var string|string[] $directory The directory (or array of dirs) to run PHPUnit on + */ + protected $directory; /** * @var string $runFrom When running PHPUnit with an XML config, the command is run from this directory @@ -14,7 +18,7 @@ class PhpUnit implements \PHPCI\Plugin protected $runFrom; /** - * @var string $xmlConfigFile The path of an xml config for PHPUnit + * @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit */ protected $xmlConfigFile;