From 140e0bbbd38aa7eb16c66e255a98dfcf98338fb1 Mon Sep 17 00:00:00 2001 From: David Yell Date: Tue, 13 May 2014 10:57:50 +0100 Subject: [PATCH] Updated the test suite dispatcher to allow use of PHPUnit from Composer Closes #3479 --- lib/Cake/TestSuite/CakeTestSuiteDispatcher.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 3f470f712..940fef400 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -136,9 +136,19 @@ class CakeTestSuiteDispatcher { if (class_exists('PHPUnit_Framework_TestCase')) { return true; } - foreach (App::path('vendors') as $vendor) { + $phpunitPath = 'phpunit' . DS . 'phpunit'; + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + $composerGlobalDir[] = env('APPDATA') . DS . 'Composer' . DS . 'vendor' . DS; + } else { + $composerGlobalDir[] = env('HOME') . DS . '.composer' . DS . 'vendor' . DS; + } + $vendors = array_merge(App::path('vendors'), $composerGlobalDir); + foreach ($vendors as $vendor) { $vendor = rtrim($vendor, DS); - if (is_dir($vendor . DS . 'PHPUnit')) { + if (is_dir($vendor . DS . $phpunitPath)) { + ini_set('include_path', $vendor . DS . $phpunitPath . PATH_SEPARATOR . ini_get('include_path')); + break; + } elseif (is_dir($vendor . DS . 'PHPUnit')) { ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path')); break; }