diff --git a/cake/tests/lib/cake_test_loader.php b/cake/tests/lib/cake_test_loader.php index c388a410e40..cbc767f0119 100644 --- a/cake/tests/lib/cake_test_loader.php +++ b/cake/tests/lib/cake_test_loader.php @@ -2,6 +2,13 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { +/** + * Load a file and find the first test case / suite in that file. + * + * @param string $filePath + * @param string $params + * @return ReflectionClass + */ public function load($filePath, $params = '') { $file = $this->_resolveTestFile($filePath, $params); @@ -50,7 +57,13 @@ public function load($filePath, $params = '') { } } } - + +/** + * Reload method. + * + * @param ReflectionClass $aClass + * @return void + */ public function reload(ReflectionClass $aClass) { return $aClass; } @@ -61,10 +74,17 @@ public function reload(ReflectionClass $aClass) { * @return void */ protected function _resolveTestFile($filePath, $params) { - $basePath = $this->_basePath($params); - return $basePath . DS . $filePath . '.test.php'; + $basePath = $this->_basePath($params) . DS . $filePath; + $ending = '.test.php'; + return (strpos($basePath, $ending) === (strlen($basePath) - strlen($ending))) ? $basePath : $basePath . $ending; } - + +/** + * Generates the base path to a set of tests based on the parameters. + * + * @param array $params + * @return string The base path. + */ protected function _basePath($params) { $result = null; if (!empty($params['core'])) { @@ -77,4 +97,5 @@ protected function _basePath($params) { } return $result; } + } diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index e61564d680d..e78d43001fb 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -86,6 +86,8 @@ function dispatch() { $this->_checkPHPUnit(); $this->_parseParams(); + require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; + if ($this->params['case']) { $value = $this->_runTestCase(); } else { @@ -244,8 +246,6 @@ function _parseParams() { * @return void */ function _runTestCase() { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; - $commandArgs = array( 'case' => $this->params['case'], 'core' =>$this->params['core'],