#6518: Can't 'CREATE TABLE test_suite_tables' when run Test Suite with
PostgreSQL.
---------------------------+------------------------------------------------
Reporter: k1LoW | Type: Bug
Status: new | Priority: Low
Milestone: 1.2.x.x | Component: General
Version: 1.2 Final | Severity: Normal
Keywords: | Php_version: PHP 5
Cake_version: 1.2.3.8166 |
---------------------------+------------------------------------------------
== Version ==
* CakePHP 1.2.3.8166
* PostgreSQL 8.3
* CakePHP Test Suite 1.2.0.0
== What I did: ==
* comment out $test from database.php
* CakePHP add 'test_suite_' prefix to test table.
* use $import = array('model' => 'User')
=== Example user_fixture.php ===
{{{
<?php
class UserFixture extends CakeTestFixture {
var $name = 'User';
var $import = array('model' => 'User');
var $records = array(array(
'id' => 1,
'name' => 'k1LoW',
'username' => 'k1low',
'password' => 'hoge',
'mail' => '[email protected]',
'created' => '2009-07-14 21:00:05',
'modified' => '2009-07-14 21:00:05'
));
}
}}}
== What I expected to happen: ==
1. CREATE TABLE test_suite_users ...
2. Run Test.
3. DROP TABLE test_suite_users
== Why it didn't meet my expectations: ==
1. '''DROP TABLE test_suite_users <- ???'''
2. CREATE TABLE test_suite_users ...
3. Run Test.
4. DROP TABLE test_suite_users
== Causal Factor ==
'''unprefix 'test_suite_' to $fixture''' in
cake/tests/lib/cake_test_case.php:start()
== Possible Fix: ==
I use PostgreSQL only, and I don't try MySQL. So this fix is for
PostgreSQL.
cake/tests/lib/cake_test_case.php start()
{{{
function start() {
if (isset($this->_fixtures) && isset($this->db)) {
Configure::write('Cache.disable', true);
$cacheSources = $this->db->cacheSources;
$this->db->cacheSources = false;
$sources = $this->db->listSources();
$this->db->cacheSources = $cacheSources;
if (!$this->dropTables) {
return;
}
foreach ($this->_fixtures as $fixture) {
if ($this->db->_baseConfig['connect'] == 'pg_connect' ||
$this->db->_baseConfig['connect'] == 'pg_pconnect') {
$table = $this->db->config['prefix'] . $fixture->table;
}
if (in_array($table, $sources)) {
$fixture->drop($this->db);
$fixture->create($this->db);
} elseif (!in_array($table, $sources)) {
$fixture->create($this->db);
}
}
}
}
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/6518>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---