From 9f5becbc33740a5efca2496030f8d881ed94a22b Mon Sep 17 00:00:00 2001 From: phpnut Date: Wed, 20 Jun 2007 03:20:59 +0000 Subject: [PATCH] Adding fix for Ticket #2737, changed TRUNCATE to TRUNCATE TABLE git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5308 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/lib/cake_test_fixture.php | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 1cde6732c..6d62e8b03 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -52,41 +52,41 @@ class CakeTestFixture extends Object { function init() { if (isset($this->import) && (is_string($this->import) || is_array($this->import))) { $import = array(); - + if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) { $import = am(array('records' => false), ife(is_array($this->import), $this->import, array())); - + $import['model'] = ife(is_array($this->import), $this->import['model'], $this->import); } else if (isset($this->import['table'])) { $import = am(array('connection' => 'default', 'records' => false), $this->import); } - + if (isset($import['model']) && (class_exists($import['model']) || loadModel($import['model']))) { $model =& new $import['model']; $modelDb =& ConnectionManager::getDataSource($model->useDbConfig); - + $info = $model->loadInfo(); - + $this->fields = array_combine(Set::extract($info->value, '{n}.name'), $info->value); $this->fields[$model->primaryKey]['key'] = 'primary'; - + $this->primaryKey = array( $model->primaryKey ); } else if (isset($import['table'])) { $model =& new stdClass(); $modelDb =& ConnectionManager::getDataSource($import['connection']); - + $model->name = Inflector::camelize(Inflector::singularize($import['table'])); $model->table = $import['table']; $model->tablePrefix = $modelDb->config['prefix']; - + $info = $modelDb->describe($model); - + $this->fields = array_combine(Set::extract($info, '{n}.name'), $info); } - + if ($import['records'] !== false && isset($model) && isset($modelDb)) { $this->records = array(); - + $query = array( 'fields' => Set::extract($this->fields, '{n}.name'), 'table' => $modelDb->name($model->table), @@ -95,19 +95,19 @@ class CakeTestFixture extends Object { 'order' => null, 'limit' => null ); - + foreach($query['fields'] as $index => $field) { $query['fields'][$index] = $modelDb->name($query['alias']) . '.' . $modelDb->name($field); } - + $records = $modelDb->fetchAll($modelDb->buildStatement($query, $model), false, $model->name); - + if ($records !== false && !empty($records)) { $this->records = Set::extract($records, '{n}.' . $model->name); } } } - + if (!isset($this->table)) { $this->table = Inflector::underscore(Inflector::pluralize($this->name)); } @@ -119,11 +119,11 @@ class CakeTestFixture extends Object { if (isset($this->primaryKey) && !is_array($this->primaryKey)) { $this->primaryKey = array( $this->primaryKey ); } - + if (isset($this->primaryKey) && isset($this->fields[$this->primaryKey[0]])) { $this->fields[$this->primaryKey[0]]['key'] = 'primary'; } - + if (isset($this->fields)) { foreach($this->fields as $index => $field) { if (empty($field['default'])) { @@ -180,7 +180,7 @@ class CakeTestFixture extends Object { $this->_create = $create; } - + return $this->_create; } /** @@ -206,7 +206,7 @@ class CakeTestFixture extends Object { */ function truncate() { if (!isset($this->_truncate)) { - $this->_truncate = 'TRUNCATE ' . $this->db->name($this->db->config['prefix'] . $this->table); + $this->_truncate = 'TRUNCATE TABLE ' . $this->db->name($this->db->config['prefix'] . $this->table); } return $this->_truncate; @@ -249,7 +249,7 @@ class CakeTestFixture extends Object { $this->_insert = $inserts; } - + return $this->_insert; } }