Permalink
Browse files

Merge pull request #1174 from psparrow/master

Fixed issue with including including PHPUnit's Autoload script.
  • Loading branch information...
2 parents 246c09a + 8ad9492 commit 76ea0803d5be55ebf43789dbcd94d01426e67ed5 @markstory markstory committed Mar 14, 2013
View
38 lib/Cake/Test/Case/TestSuite/CakeTestSuiteDispatcherTest.php
@@ -0,0 +1,38 @@
+<?php
+
+class CakeTestSuiteDispatcherTest extends CakeTestCase {
+
+ public function setUp() {
+ $this->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");
+ }
+
+}
View
5 lib/Cake/TestSuite/CakeTestSuiteDispatcher.php
@@ -138,13 +138,14 @@ protected function _checkPHPUnit() {
*/
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;
}
/**

0 comments on commit 76ea080

Please sign in to comment.