From 848461f7a0d82e39b06969f9adf5728be97e5b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 01:49:36 -0430 Subject: [PATCH] Making the testsuite run again --- lib/Cake/Console/Command/Task/ExtractTask.php | 2 +- lib/Cake/Console/Command/TestSuiteShell.php | 10 +++++----- lib/Cake/Model/ConnectionManager.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 6 +++--- .../TestSuite/Fixture/CakeFixtureManager.php | 19 ++----------------- lib/Cake/TestSuite/Fixture/CakeTestModel.php | 3 ++- lib/Cake/TestSuite/TestManager.php | 10 +++++----- lib/Cake/TestSuite/TestRunner.php | 2 +- lib/Cake/tests/cases/libs/xml.test.php | 3 ++- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 89af9153c..e79df6b8d 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -114,7 +114,7 @@ class ExtractTask extends Shell { $this->__paths = explode(',', $this->params['paths']); } else { $defaultPath = APP_PATH; - $message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $this->Dispatch->params['root'] . DS . 'myapp'); + $message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $defaultPath); while (true) { $response = $this->in($message, null, $defaultPath); if (strtoupper($response) === 'Q') { diff --git a/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestSuiteShell.php index 8814242a2..3b3b1f901 100644 --- a/lib/Cake/Console/Command/TestSuiteShell.php +++ b/lib/Cake/Console/Command/TestSuiteShell.php @@ -19,6 +19,11 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('CakeTestSuiteDispatcher', 'TestSuite'); +App::uses('TestRunner', 'TestSuite'); +App::uses('TestManager', 'TestSuite'); + class TestSuiteShell extends Shell { /** @@ -155,8 +160,6 @@ class TestSuiteShell extends Shell { * @return void */ public function initialize() { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_dispatcher.php'; - $corePath = App::core('cake'); if (isset($corePath[0])) { define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); @@ -166,7 +169,6 @@ class TestSuiteShell extends Shell { $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; } /** @@ -252,8 +254,6 @@ class TestSuiteShell extends Shell { * @return void */ protected function run($runnerArgs, $options = array()) { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php'; - restore_error_handler(); restore_error_handler(); diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 208d6ba9d..324dcf554 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -230,7 +230,7 @@ class ConnectionManager { if (!empty(self::$config->{$name})) { self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); } else { - throw new MissingConnectionException(array('class' => 'ConnectionManager')); + throw new MissingConnectionException(array('class' => $name)); } } diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 184dc7912..95819c5e1 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -20,9 +20,9 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE_TESTS_LIB . 'cake_fixture_manager.php'; -require_once CAKE_TESTS_LIB . 'cake_test_model.php'; -require_once CAKE_TESTS_LIB . 'cake_test_fixture.php'; +App::uses('CakeFixtureManager', 'TestSuite/Fixture'); +App::uses('CakeTestModel', 'TestSuite/Fixture'); +App::uses('CakeTestFixture', 'TestSuite/Fixture'); /** * CakeTestCase class diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index 099da5557..ea09473e7 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -55,7 +55,7 @@ class CakeFixtureManager { * @param CakeTestCase $test the test case to inspect * @return void */ - public function fixturize(CakeTestCase $test) { + public function fixturize($test) { if (empty($test->fixtures) || !empty($this->_processed[get_class($test)])) { $test->db = $this->_db; return; @@ -81,22 +81,7 @@ class CakeFixtureManager { if ($this->_initialized) { return; } - $testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects())); - - $_prefix = null; - - if ($testDbAvailable) { - // Try for test DB - @$db = ConnectionManager::getDataSource('test'); - $testDbAvailable = $db->isConnected(); - } else { - throw new MissingConnectionException(__('You need to create a $test datasource connection to start using fixtures')); - } - - if (!$testDbAvailable) { - throw new MissingConnectionException(__('Unable to connect to the $test datasource')); - } - + $db = ConnectionManager::getDataSource('test'); $this->_db = $db; ClassRegistry::config(array('ds' => 'test')); $this->_initialized = true; diff --git a/lib/Cake/TestSuite/Fixture/CakeTestModel.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php index 819c3cbe2..6c7d3d4b3 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestModel.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -17,7 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once LIBS.'model'.DS.'model.php'; + +App::uses('Model', 'Model'); /** * Short description for class. diff --git a/lib/Cake/TestSuite/TestManager.php b/lib/Cake/TestSuite/TestManager.php index f4f5b4571..cf56a20b7 100644 --- a/lib/Cake/TestSuite/TestManager.php +++ b/lib/Cake/TestSuite/TestManager.php @@ -17,13 +17,15 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); -define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups'); +define('CORE_TEST_CASES', LIBS . 'tests' . DS . 'cases'); +define('CORE_TEST_GROUPS', LIBS . 'tests' . DS . 'groups'); define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_GROUPS', TESTS . 'groups'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; +App::uses('CakeTestSuite', 'TestSuite'); +App::uses('CakeTestCase', 'TestSuite'); +App::uses('CakeFixtureManager', 'TestSuite/Fixture'); /** * TestManager is the base class that handles loading and initiating the running @@ -88,8 +90,6 @@ class TestManager { * @return void */ public function __construct($params = array()) { - require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); - $this->params = $params; if (isset($params['app'])) { $this->appTest = true; diff --git a/lib/Cake/TestSuite/TestRunner.php b/lib/Cake/TestSuite/TestRunner.php index c2ca7f809..afd299e3a 100644 --- a/lib/Cake/TestSuite/TestRunner.php +++ b/lib/Cake/TestSuite/TestRunner.php @@ -20,7 +20,7 @@ require 'PHPUnit/TextUI/Command.php'; -require_once 'test_manager.php'; +App::uses('TestManager', 'TestSuite'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); diff --git a/lib/Cake/tests/cases/libs/xml.test.php b/lib/Cake/tests/cases/libs/xml.test.php index 666a4f45d..ee00efd2b 100644 --- a/lib/Cake/tests/cases/libs/xml.test.php +++ b/lib/Cake/tests/cases/libs/xml.test.php @@ -17,7 +17,8 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Xml'); +App::uses('Xml', 'Utility'); +App::uses('CakeTestModel', 'TestSuite/Fixture'); /** * Article class