From ffc7d1c1b98d69ddf889a5941a16baeb17a438e8 Mon Sep 17 00:00:00 2001 From: Corpsee Date: Sun, 9 Mar 2014 00:30:00 +0700 Subject: [PATCH 1/4] Fixed findBinary function for windows (which -> where) --- PHPCI/Helper/CommandExecutor.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index 60061404..5c64dd45 100644 --- a/PHPCI/Helper/CommandExecutor.php +++ b/PHPCI/Helper/CommandExecutor.php @@ -118,11 +118,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; } } From c3b9e62adf629186b013c67252628dd3d010cf3d Mon Sep 17 00:00:00 2001 From: Corpsee Date: Sun, 9 Mar 2014 00:30:32 +0700 Subject: [PATCH 2/4] Fixed composer plugin for using on Windows --- PHPCI/Plugin/Composer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); From 76c9676be3ec16e603e5b00cf4e2ee0299597b98 Mon Sep 17 00:00:00 2001 From: Corpsee Date: Sun, 9 Mar 2014 01:44:54 +0700 Subject: [PATCH 3/4] Added phpunit config/bootstrap files for autostart all tests --- Tests/bootstrap.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ composer.json | 2 +- phpunit.xml | 24 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Tests/bootstrap.php create mode 100644 phpunit.xml 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/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 + + + From e7bca0636377c11862a4092f15f0b25930952b29 Mon Sep 17 00:00:00 2001 From: Corpsee Date: Sun, 9 Mar 2014 01:46:03 +0700 Subject: [PATCH 4/4] Fixed unittests on windows --- PHPCI/Helper/CommandExecutor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index 5c64dd45..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); }