Renaming tests folders and making tests runnable again

This commit is contained in:
Jose Lorenzo Rodriguez 2011-04-10 20:08:24 -04:30
parent 7f31cfb173
commit 0263ffc74e
278 changed files with 21 additions and 24 deletions

View file

@ -38,7 +38,7 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
*/ */
protected function _resolveTestFile($filePath, $params) { protected function _resolveTestFile($filePath, $params) {
$basePath = $this->_basePath($params) . DS . $filePath; $basePath = $this->_basePath($params) . DS . $filePath;
$ending = '.test.php'; $ending = 'Test.php';
return (strpos($basePath, $ending) === (strlen($basePath) - strlen($ending))) ? $basePath : $basePath . $ending; return (strpos($basePath, $ending) === (strlen($basePath) - strlen($ending))) ? $basePath : $basePath . $ending;
} }
@ -56,7 +56,7 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
$result = APP_TEST_CASES; $result = APP_TEST_CASES;
} else if (!empty($params['plugin'])) { } else if (!empty($params['plugin'])) {
$pluginPath = App::pluginPath($params['plugin']); $pluginPath = App::pluginPath($params['plugin']);
$result = $pluginPath . 'tests' . DS . 'cases'; $result = $pluginPath . 'tests' . DS . 'Case';
} }
return $result; return $result;
} }
@ -72,7 +72,9 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
$testCases = array(); $testCases = array();
foreach ($fileList as $testCaseFile) { foreach ($fileList as $testCaseFile) {
$testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile); $case = str_replace($directory . DS, '', $testCaseFile);
$case = str_replace('Test.php', '', $case);
$testCases[$testCaseFile] = $case;
} }
return $testCases; return $testCases;
} }
@ -92,7 +94,7 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
$files = new RegexIterator( $files = new RegexIterator(
new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)), new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)),
'/.*\.test.php$/' '/.*Test.php$/'
); );
foreach ($files as $file) { foreach ($files as $file) {

View file

@ -17,8 +17,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
define('CORE_TEST_CASES', LIBS . 'tests' . DS . 'cases'); define('CORE_TEST_CASES', LIBS . 'tests' . DS . 'Case');
define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_CASES', TESTS . 'Case');
App::uses('CakeTestSuiteCommand', 'TestSuite'); App::uses('CakeTestSuiteCommand', 'TestSuite');

View file

@ -105,43 +105,38 @@ class CakeFixtureManager {
if (strpos($fixture, 'core.') === 0) { if (strpos($fixture, 'core.') === 0) {
$fixture = substr($fixture, strlen('core.')); $fixture = substr($fixture, strlen('core.'));
$fixturePaths[] = LIBS . 'tests' . DS . 'fixtures'; $fixturePaths[] = LIBS . 'tests' . DS . 'Fixture';
} elseif (strpos($fixture, 'app.') === 0) { } elseif (strpos($fixture, 'app.') === 0) {
$fixture = substr($fixture, strlen('app.')); $fixture = substr($fixture, strlen('app.'));
$fixturePaths = array( $fixturePaths = array(
TESTS . 'fixtures', TESTS . 'Fixture'
VENDORS . 'tests' . DS . 'fixtures'
); );
} elseif (strpos($fixture, 'plugin.') === 0) { } elseif (strpos($fixture, 'plugin.') === 0) {
$parts = explode('.', $fixture, 3); $parts = explode('.', $fixture, 3);
$pluginName = $parts[1]; $pluginName = $parts[1];
$fixture = $parts[2]; $fixture = $parts[2];
$fixturePaths = array( $fixturePaths = array(
App::pluginPath($pluginName) . 'tests' . DS . 'fixtures', App::pluginPath($pluginName) . 'tests' . DS . 'Fixture',
TESTS . 'fixtures', TESTS . 'Fixture'
VENDORS . 'tests' . DS . 'fixtures'
); );
} else { } else {
$fixturePaths = array( $fixturePaths = array(
TESTS . 'fixtures', TESTS . 'Fixture',
VENDORS . 'tests' . DS . 'fixtures', LIBS . 'tests' . DS . 'Fixture'
LIBS . DS . 'cake' . DS . 'tests' . DS . 'fixtures'
); );
} }
foreach ($fixturePaths as $path) { foreach ($fixturePaths as $path) {
if (is_readable($path . DS . $fixture . '_fixture.php')) { $className = Inflector::camelize($fixture);
$fixtureFile = $path . DS . $fixture . '_fixture.php'; if (is_readable($path . DS . $className . 'Fixture.php')) {
$fixtureFile = $path . DS . $className . 'Fixture.php';
require_once($fixtureFile);
$fixtureClass = $className . 'Fixture';
$this->_loaded[$fixtureIndex] = new $fixtureClass($this->_db);
$this->_fixtureMap[$fixtureClass] = $this->_loaded[$fixtureIndex];
break; break;
} }
} }
if (isset($fixtureFile)) {
require_once($fixtureFile);
$fixtureClass = Inflector::camelize($fixture) . 'Fixture';
$this->_loaded[$fixtureIndex] = new $fixtureClass($this->_db);
$this->_fixtureMap[$fixtureClass] = $this->_loaded[$fixtureIndex];
}
} }
} }

Some files were not shown because too many files have changed in this diff Show more