From dae10c19772386fe933d9c11f5ff8d58f02d74c4 Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Wed, 15 May 2013 23:26:49 -0400 Subject: [PATCH] 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; } }