mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Start removal of magin "test_suite" connection
This commit is contained in:
parent
e89860e079
commit
9d2e4b1b04
4 changed files with 40 additions and 15 deletions
|
@ -91,21 +91,12 @@ class CakeFixtureManager {
|
|||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@ require_once LIBS.'model'.DS.'model.php';
|
|||
* @subpackage cake.cake.tests.lib
|
||||
*/
|
||||
class CakeTestModel extends Model {
|
||||
public $useDbConfig = 'test_suite';
|
||||
public $useDbConfig = 'test';
|
||||
public $cacheSources = false;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,14 @@ class CakeTestSuiteDispatcher {
|
|||
* @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
cake/tests/lib/templates/missing_conenction.php
Normal file
27
cake/tests/lib/templates/missing_conenction.php
Normal file
|
@ -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'; ?>
|
Loading…
Add table
Reference in a new issue