From 5038e7eb38aa7a77584f0a26cb484547c1e667a9 Mon Sep 17 00:00:00 2001 From: pjskeptic Date: Tue, 12 Mar 2013 22:02:55 -0400 Subject: [PATCH 1/3] Fixed PHPUnit include bug. Fixed vendor include path bug. --- lib/Cake/TestSuite/CakeTestSuiteDispatcher.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 6b8e653e0..86dfd3895 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -138,13 +138,14 @@ class CakeTestSuiteDispatcher { */ public function loadTestFramework() { foreach (App::path('vendors') as $vendor) { - if (is_dir($vendor . 'PHPUnit')) { + $vendor = rtrim($vendor, DS); + if (is_dir($vendor . DS . 'PHPUnit')) { ini_set('include_path', $vendor . PATH_SEPARATOR . ini_get('include_path')); break; } } - return include 'PHPUnit' . DS . 'Autoload.php'; + return (include('PHPUnit' . DS . 'Autoload.php')) !== false; } /** From b17d8c91244365351a4e9bff7a64d0aa4ec998cd Mon Sep 17 00:00:00 2001 From: pjskeptic Date: Tue, 12 Mar 2013 23:34:30 -0400 Subject: [PATCH 2/3] Added test for CakeTestSuiteDispatcher::loadTestFramework. --- .../TestSuite/CakeTestSuiteDispatcherTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php new file mode 100644 index 000000000..be676240a --- /dev/null +++ b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php @@ -0,0 +1,28 @@ + array('junk')), App::RESET); + ini_set('include_path', 'junk'); + } + + public function testLoadTestFramework() { + $dispatcher = new CakeTestSuiteDispatcher(); + + $this->assertTrue($dispatcher->loadTestFramework()); + + $this->clearPaths(); + + $exception = null; + + try { + $dispatcher->loadTestFramework(); + } catch(Exception $ex) { + $exception = $ex; + } + + $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning"); + } + +} From 294dff7a2644134b3a65240104a801885324e91e Mon Sep 17 00:00:00 2001 From: pjskeptic Date: Tue, 12 Mar 2013 23:34:30 -0400 Subject: [PATCH 3/3] Added test for CakeTestSuiteDispatcher::loadTestFramework. --- .../TestSuite/CakeTestSuiteDispatcherTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php new file mode 100644 index 000000000..9fe0fd13d --- /dev/null +++ b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php @@ -0,0 +1,38 @@ +vendors = App::path('vendors'); + $this->includePath = ini_get('include_path'); + } + + public function tearDown() { + App::build(array('Vendor' => $this->vendors), App::RESET); + ini_set('include_path', $this->includePath); + } + + protected function clearPaths() { + App::build(array('Vendor' => array('junk')), App::RESET); + ini_set('include_path', 'junk'); + } + + public function testLoadTestFramework() { + $dispatcher = new CakeTestSuiteDispatcher(); + + $this->assertTrue($dispatcher->loadTestFramework()); + + $this->clearPaths(); + + $exception = null; + + try { + $dispatcher->loadTestFramework(); + } catch(Exception $ex) { + $exception = $ex; + } + + $this->assertEquals(get_class($exception), "PHPUnit_Framework_Error_Warning"); + } + +}