diff --git a/PHPCI/Application.php b/PHPCI/Application.php index 03e878d7..3d889967 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -24,7 +24,7 @@ class Application extends b8\Application { $request =& $this->request; $route = '/:controller/:action'; - $opts = ['controller' => 'Home', 'action' => 'index']; + $opts = array('controller' => 'Home', 'action' => 'index'); $this->router->clearRoutes(); $this->router->register($route, $opts, function (&$route, Response &$response) use (&$request) { diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index 60061404..9b7fe442 100644 --- a/PHPCI/Helper/CommandExecutor.php +++ b/PHPCI/Helper/CommandExecutor.php @@ -75,6 +75,10 @@ class CommandExecutor $status = 0; exec($command, $this->lastOutput, $status); + foreach ($this->lastOutput as &$lastOutput) { + $lastOutput = trim($lastOutput, '"'); + } + if (!empty($this->lastOutput) && ($this->verbose|| $status != 0)) { $this->logger->log($this->lastOutput); } @@ -118,11 +122,12 @@ class CommandExecutor return $this->rootDir . 'vendor/bin/' . $bin; } - // Use "which" - $which = trim(shell_exec('which ' . $bin)); + // Use "where" for windows and "which" for other OS + $findCmd = (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') ? 'which' : 'where'; + $findCmdResult = trim(shell_exec($findCmd . ' ' . $bin)); - if (!empty($which)) { - return $which; + if (!empty($findCmdResult)) { + return $findCmdResult; } } diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index 1af4abf6..0b89afe0 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -45,8 +45,11 @@ class Composer implements \PHPCI\Plugin $this->phpci->logFailure('Could not find Composer.'); return false; } - - $cmd = $composerLocation . ' --no-ansi --no-interaction '; + $cmd = ''; + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $cmd = 'php '; + } + $cmd .= $composerLocation . ' --no-ansi --no-interaction '; $cmd .= ($this->preferDist ? '--prefer-dist' : null) . ' --working-dir="%s" %s'; return $this->phpci->executeCommand($cmd, $this->directory, $this->action); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php new file mode 100644 index 00000000..50b285c5 --- /dev/null +++ b/Tests/bootstrap.php @@ -0,0 +1,44 @@ +loadYaml(dirname(__DIR__) . '/PHPCI/config.yml'); +} + +require_once(dirname(__DIR__) . '/vars.php'); diff --git a/composer.json b/composer.json index acafd3a5..7ccbc600 100644 --- a/composer.json +++ b/composer.json @@ -34,11 +34,11 @@ }, "require-dev": { + "phpunit/phpunit": "3.7.*", "phpspec/prophecy-phpunit": "1.*" }, "suggest": { - "phpunit/phpunit": "PHP unit testing framework", "phpmd/phpmd": "PHP Mess Detector", "sebastian/phpcpd": "PHP Copy/Paste Detector", "squizlabs/php_codesniffer": "PHP Code Sniffer", diff --git a/daemonise b/daemonise index 45751190..5117e414 100755 --- a/daemonise +++ b/daemonise @@ -15,7 +15,7 @@ require('bootstrap.php'); use PHPCI\Command\DaemoniseCommand; use Symfony\Component\Console\Application; -$loggerConfig = \PHPCI\Helper\LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php"); +$loggerConfig = \PHPCI\Logging\LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php"); $application = new Application(); $application->add(new DaemoniseCommand($loggerConfig->getFor('DaemoniseCommand'))); diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..15bd43aa --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,24 @@ + + + + + + ./Tests/PHPCI/Helper + + + ./Tests/PHPCI/Logging + + + ./Tests/PHPCI/Plugin + + +