mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Moving a require.
Adding some doc blocks, and making the loader not double append test case suffixes.
This commit is contained in:
parent
08fba9b280
commit
f84046c802
2 changed files with 27 additions and 6 deletions
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader {
|
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 = '') {
|
public function load($filePath, $params = '') {
|
||||||
$file = $this->_resolveTestFile($filePath, $params);
|
$file = $this->_resolveTestFile($filePath, $params);
|
||||||
|
|
||||||
|
@ -51,6 +58,12 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload method.
|
||||||
|
*
|
||||||
|
* @param ReflectionClass $aClass
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function reload(ReflectionClass $aClass) {
|
public function reload(ReflectionClass $aClass) {
|
||||||
return $aClass;
|
return $aClass;
|
||||||
}
|
}
|
||||||
|
@ -61,10 +74,17 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _resolveTestFile($filePath, $params) {
|
protected function _resolveTestFile($filePath, $params) {
|
||||||
$basePath = $this->_basePath($params);
|
$basePath = $this->_basePath($params) . DS . $filePath;
|
||||||
return $basePath . DS . $filePath . '.test.php';
|
$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) {
|
protected function _basePath($params) {
|
||||||
$result = null;
|
$result = null;
|
||||||
if (!empty($params['core'])) {
|
if (!empty($params['core'])) {
|
||||||
|
@ -77,4 +97,5 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,8 @@ class CakeTestSuiteDispatcher {
|
||||||
$this->_checkPHPUnit();
|
$this->_checkPHPUnit();
|
||||||
$this->_parseParams();
|
$this->_parseParams();
|
||||||
|
|
||||||
|
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
|
||||||
|
|
||||||
if ($this->params['case']) {
|
if ($this->params['case']) {
|
||||||
$value = $this->_runTestCase();
|
$value = $this->_runTestCase();
|
||||||
} else {
|
} else {
|
||||||
|
@ -244,8 +246,6 @@ class CakeTestSuiteDispatcher {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _runTestCase() {
|
function _runTestCase() {
|
||||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
|
|
||||||
|
|
||||||
$commandArgs = array(
|
$commandArgs = array(
|
||||||
'case' => $this->params['case'],
|
'case' => $this->params['case'],
|
||||||
'core' =>$this->params['core'],
|
'core' =>$this->params['core'],
|
||||||
|
|
Loading…
Reference in a new issue