From 1372a8192678ada22781cbce33b177c667670f56 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 15:53:00 -0400 Subject: [PATCH 1/5] Ignore Eclipse environment files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5c17a79b..8083e865 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ composer.lock composer.phar config.php .DS_Store +.settings/ +.project +.buildpath From 440d60066533de8ac61df9bfc9d6bdbc10200873 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 20:26:45 -0400 Subject: [PATCH 2/5] Fixed error about using $this outside of object context --- PHPCI/Builder.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index 58c50d70..d3ec7fac 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -104,8 +104,6 @@ class Builder { $cb($prefix . $item); } - - $this->log .= $prefix . $item . PHP_EOL; }, $message); } else From dae10c19772386fe933d9c11f5ff8d58f02d74c4 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 23:26:49 -0400 Subject: [PATCH 3/5] Added phpunit flag to allow running tests from an alternate working directory --- PHPCI/Plugin/PhpUnit.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index 910743d5..591ec571 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -7,6 +7,7 @@ class PhpUnit implements \PHPCI\Plugin protected $directory; protected $args; protected $phpci; + protected $runFrom; /** * @var string $xmlConfigFile The path of an xml config for PHPUnit @@ -18,6 +19,7 @@ class PhpUnit implements \PHPCI\Plugin $this->phpci = $phpci; $this->directory = isset($options['directory']) ? $options['directory'] : null; $this->xmlConfigFile = isset($options['config']) ? $options['config'] : null; + $this->runFrom = isset($options['run_from']) ? $options['run_from'] : null; $this->args = isset($options['args']) ? $options['args'] : ''; } @@ -48,7 +50,15 @@ class PhpUnit implements \PHPCI\Plugin } else { - return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $configPath); + if ($this->runFrom) { + $curdir = getcwd(); + chdir($this->phpci->buildPath.'/'.$this->runFrom); + } + $success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $configPath); + if ($this->runFrom) { + chdir($curdir); + } + return $success; } } From d3f61ab79e7a8e2e281afa00701dc53037f20ff2 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 23:43:34 -0400 Subject: [PATCH 4/5] Getting to the bottom of the logging issue --- PHPCI/Builder.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index d3ec7fac..b1aec937 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -96,15 +96,17 @@ class Builder if(is_array($message)) { - $cb = $this->logCallback; - - $message = array_map(function($item) use ($cb, $prefix) + + foreach ($message as $item) { - if(is_callable($cb)) + if(is_callable($this->logCallback)) { - $cb($prefix . $item); + $this->logCallback($prefix . $item); } - }, $message); + + $this->log .= $prefix . $item . PHP_EOL; + } + } else { From ead7f9a5eb5e5d09a73f42ec636a9eaf7cdbf59a Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 23:50:21 -0400 Subject: [PATCH 5/5] Added comments --- PHPCI/Plugin/PhpUnit.php | 10 +++++++--- README.md | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index 591ec571..1ed744fc 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -7,11 +7,15 @@ class PhpUnit implements \PHPCI\Plugin protected $directory; protected $args; protected $phpci; + + /** + * @var string $runFrom When running PHPUnit with an XML config, the command is run from this directory + */ protected $runFrom; -/** - * @var string $xmlConfigFile The path of an xml config for PHPUnit - */ + /** + * @var string $xmlConfigFile The path of an xml config for PHPUnit + */ protected $xmlConfigFile; public function __construct(\PHPCI\Builder $phpci, array $options = array()) diff --git a/README.md b/README.md index 5ab5bb3b..1c611cc4 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Similar to Travis CI, to support PHPCI in your project, you simply need to add a - "PHPUnit-ubuntu-fix.xml" directory: - "tests/" + run_from: "phpunit/" php_mess_detector: allow_failures: true php_code_sniffer: