Skip to content

Commit

Permalink
Start removal of magin "test_suite" connection
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo authored and markstory committed Sep 25, 2010
1 parent e89860e commit 9d2e4b1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
15 changes: 3 additions & 12 deletions cake/tests/lib/cake_fixture_manager.php
Expand Up @@ -91,21 +91,12 @@ protected function _initDb() {
$testDbAvailable = $db->isConnected();
}

// Try for default DB
if (!$testDbAvailable) {
$db = ConnectionManager::getDataSource('default');
$_prefix = $db->config['prefix'];
$db->config['prefix'] = 'test_suite_';
throw new MissingConnectionException(__('You need to create a $test datasource connection to start using fixtures'));
}

ConnectionManager::create('test_suite', $db->config);
$db->config['prefix'] = $_prefix;

// Get db connection
$this->_db = ConnectionManager::getDataSource('test_suite');
$this->_db->cacheSources = false;

ClassRegistry::config(array('ds' => 'test_suite'));
$this->_db = $db;
ClassRegistry::config(array('ds' => 'test'));
$this->_initialized = true;
}

Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/cake_test_model.php
Expand Up @@ -26,6 +26,6 @@
* @subpackage cake.cake.tests.lib
*/
class CakeTestModel extends Model {
public $useDbConfig = 'test_suite';
public $useDbConfig = 'test';
public $cacheSources = false;
}
11 changes: 9 additions & 2 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -272,7 +272,14 @@ function _parseParams() {
* @return void
*/
function _runTestCase() {
$Reporter = CakeTestSuiteDispatcher::getReporter();
return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
try {
$Reporter = CakeTestSuiteDispatcher::getReporter();
return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
} catch (MissingConnectionException $exception) {
ob_end_clean();
$baseDir = $this->_baseDir;
include CAKE_TESTS_LIB . 'templates' . DS . 'missing_conenction.php';
exit();
}
}
}
27 changes: 27 additions & 0 deletions cake/tests/lib/templates/missing_conenction.php
@@ -0,0 +1,27 @@
<?php
/**
* Missing Connection error page
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.2.0.4433
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
?>
<?php include dirname(__FILE__) . DS . 'header.php'; ?>
<div id="content">
<h2>Missing Test Database Connection</h2>
<h3><?php echo $exception->getMessage(); ?></h3>
<pre><?php echo $exception->getTraceAsString(); ?></pre>
</div>
<?php include dirname(__FILE__) . DS . 'footer.php'; ?>

0 comments on commit 9d2e4b1

Please sign in to comment.