mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Simplifying parameter parsing when importing structure / records from a fixture. Flushing registry after processing import so related models DB config remain unchanged
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7870 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
400fadd091
commit
a194f6a25e
1 changed files with 4 additions and 16 deletions
|
@ -64,27 +64,15 @@ class CakeTestFixture extends Object {
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
|
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
|
||||||
$import = array();
|
$import = array_merge(array('connection' => 'default', 'records' => false), is_array($this->import) ? $this->import : array('model' => $this->import));
|
||||||
|
|
||||||
if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) {
|
if (isset($import['model']) && App::import('Model', $import['model'])) {
|
||||||
$import = array_merge(array('connection' => 'default', 'records' => false), is_array($this->import) ? $this->import : array());
|
$model =& ClassRegistry::init(array('class' => $import['model'], 'ds' => $import['connection']));
|
||||||
$import['model'] = is_array($this->import) ? $this->import['model'] : $this->import;
|
|
||||||
} elseif (isset($this->import['table'])) {
|
|
||||||
$import = array_merge(array('connection' => 'default', 'records' => false), $this->import);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($import['model']) && (class_exists($import['model']) || App::import('Model', $import['model']))) {
|
|
||||||
$connection = isset($import['connection'])
|
|
||||||
? $import['connection']
|
|
||||||
: 'default';
|
|
||||||
ClassRegistry::config(array('ds' => $connection));
|
|
||||||
$model =& ClassRegistry::init($import['model']);
|
|
||||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||||
$db->cacheSources = false;
|
$db->cacheSources = false;
|
||||||
$this->fields = $model->schema(true);
|
$this->fields = $model->schema(true);
|
||||||
$this->fields[$model->primaryKey]['key'] = 'primary';
|
$this->fields[$model->primaryKey]['key'] = 'primary';
|
||||||
ClassRegistry::config(array('ds' => 'test_suite'));
|
ClassRegistry::flush();
|
||||||
ClassRegistry::removeObject($model->alias);
|
|
||||||
} elseif (isset($import['table'])) {
|
} elseif (isset($import['table'])) {
|
||||||
$model =& new Model(null, $import['table'], $import['connection']);
|
$model =& new Model(null, $import['table'], $import['connection']);
|
||||||
$db =& ConnectionManager::getDataSource($import['connection']);
|
$db =& ConnectionManager::getDataSource($import['connection']);
|
||||||
|
|
Loading…
Add table
Reference in a new issue