Skip to content

Commit

Permalink
Moving a require.
Browse files Browse the repository at this point in the history
Adding some doc blocks, and making the loader not double append test case suffixes.
  • Loading branch information
markstory committed Feb 13, 2011
1 parent 08fba9b commit f84046c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions cake/tests/lib/cake_test_loader.php
Expand Up @@ -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);

Expand Down Expand Up @@ -50,7 +57,13 @@ public function load($filePath, $params = '') {
}
}
}


/**
* Reload method.
*
* @param ReflectionClass $aClass
* @return void
*/
public function reload(ReflectionClass $aClass) {
return $aClass;
}
Expand All @@ -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'])) {
Expand All @@ -77,4 +97,5 @@ protected function _basePath($params) {
}
return $result;
}

}
4 changes: 2 additions & 2 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit f84046c

Please sign in to comment.