Making the test suite load again

This commit is contained in:
José Lorenzo Rodríguez 2011-02-13 23:56:41 -04:30
parent 1b38d7c851
commit f8b51bfd92
6 changed files with 36 additions and 21 deletions

View file

@ -20,8 +20,8 @@
*/ */
App::uses('CakeTestSuiteDispatcher', 'TestSuite'); App::uses('CakeTestSuiteDispatcher', 'TestSuite');
App::uses('TestRunner', 'TestSuite'); App::uses('CakeTestSuiteCommand', 'TestSuite');
App::uses('TestManager', 'TestSuite'); App::uses('CakeTestLoader', 'TestSuite');
class TestSuiteShell extends Shell { class TestSuiteShell extends Shell {
@ -163,7 +163,6 @@ class TestSuiteShell extends Shell {
public function initialize() { public function initialize() {
$this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher = new CakeTestSuiteDispatcher();
$this->_dispatcher->loadTestFramework(); $this->_dispatcher->loadTestFramework();
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
} }
/** /**

View file

@ -406,6 +406,15 @@ class MissingModelException extends CakeException {
protected $_messageTemplate = 'Model %s could not be found.'; protected $_messageTemplate = 'Model %s could not be found.';
} }
/**
* Exception Raised when a test loader could not be found
*
* @package cake.libs
*/
class MissingTestLoaderException extends CakeException {
protected $_messageTemplate = 'Test loader %s could not be found.';
}
/** /**
* Exception class for Cache. This exception will be thrown from Cache when it * Exception class for Cache. This exception will be thrown from Cache when it

View file

@ -30,7 +30,7 @@ App::uses('CakeTestFixture', 'TestSuite/Fixture');
abstract class CakeTestCase extends PHPUnit_Framework_TestCase { abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/** /**
* The class responsible for managinf the creation, loading and removing of fixtures * The class responsible for managing the creation, loading and removing of fixtures
* *
* @var CakeFixtureManager * @var CakeFixtureManager
* @access public * @access public

View file

@ -16,17 +16,14 @@
* @since CakePHP(tm) v 2.0 * @since CakePHP(tm) v 2.0
* @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', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases');
define('APP_TEST_CASES', TESTS . 'cases');
require 'PHPUnit/TextUI/Command.php'; require 'PHPUnit/TextUI/Command.php';
require_once CAKE_TESTS_LIB . 'cake_test_runner.php'; App::uses('CakeTestRunner', 'TestSuite');
require_once CAKE_TESTS_LIB . 'cake_test_loader.php'; App::uses('CakeTestLoader', 'TestSuite');
require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; App::uses('CakeTestSuite', 'TestSuite');
require_once CAKE_TESTS_LIB . 'cake_test_case.php'; App::uses('CakeTestCase', 'TestSuite');
require_once CAKE_TESTS_LIB . 'controller_test_case.php'; App::uses('ControllerTestCase', 'TestSuite');
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
@ -43,6 +40,9 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
* @param array $params list of options to be used for this run * @param array $params list of options to be used for this run
*/ */
public function __construct($loader, $params = array()) { public function __construct($loader, $params = array()) {
if (!class_exists($loader)) {
throw new MissingTestLoaderException;
}
$this->arguments['loader'] = $loader; $this->arguments['loader'] = $loader;
$this->arguments['test'] = $params['case']; $this->arguments['test'] = $params['case'];
$this->arguments['testFile'] = $params; $this->arguments['testFile'] = $params;
@ -161,13 +161,14 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
$type = strtolower($reporter); $type = strtolower($reporter);
$coreClass = 'Cake' . ucwords($reporter) . 'Reporter'; $coreClass = 'Cake' . ucwords($reporter) . 'Reporter';
$coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php'; App::uses($coreClass, 'TestSuite/Reporter');
$appClass = $reporter . 'Reporter'; $appClass = $reporter . 'Reporter';
$appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php'; App::uses($appClass, 'TestSuite/Reporter');
if (include_once $coreFile) {
if (!class_exists($appClass)) {
$object = new $coreClass(null, $this->_params); $object = new $coreClass(null, $this->_params);
} elseif (include_once $appFile) { } else {
$object = new $appClass(null, $this->_params); $object = new $appClass(null, $this->_params);
} }
return $this->arguments['printer'] = $object; return $this->arguments['printer'] = $object;

View file

@ -17,6 +17,11 @@
* @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('APP_TEST_CASES', TESTS . 'cases');
App::uses('CakeTestSuiteCommand', 'TestSuite');
/** /**
* CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action. * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action.
* *
@ -87,8 +92,6 @@ 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 {

View file

@ -19,9 +19,12 @@
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
require_once CAKE . 'libs' . DS . 'dispatcher.php'; App::uses('Dispatcher', 'Routing');
require_once CAKE_TESTS_LIB . 'cake_test_case.php'; App::uses('CakeTestCase', 'TestSuite');
App::import('Core', array('Router', 'CakeRequest', 'CakeResponse', 'Helper')); App::uses('Router', 'Routing');
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
App::uses('Helper', 'View');
/** /**
* ControllerTestDispatcher class * ControllerTestDispatcher class