#5877: Model tests with fixtures fail since rev. 7870
---------------------------+------------------------------------------------
Reporter: rikman | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Test Suite
Version: | Severity: Major
Keywords: | Php_version: PHP 5
Cake_version: 1.2.0.7870 |
---------------------------+------------------------------------------------
Since CakePHP 1.2.0.7870 my model tests are failing with "Error: Database
table model_table for model ModelName was not found."
(i) Fixtures Setup (comments and wihitespaces stripped out)
user_group_fixture.php:
class UserGroupFixture extends CakeTestFixture
{
public $name = 'UserGroup';
public $import = array('model' => 'UserGroup', 'records' => true);
}
user_fixture.php:
class UserFixture extends CakeTestFixture
{
public $name = 'User';
public $import = array('model' => 'User', 'records' => false);
public $records = array(
array(
'id' => 1,
'user_group_id' => 2,
'name' => 'foo',
'password' =>
'288f5ed10f9b731149ad3e3bcdd6add568bb61a3',
'salt' => '34da1b0c',
(...)
)
);
}
(ii) Using imports
Schema is imported in all fixtures, records just in some fixtures.
(iii) Initializing of models
The models are initialized with ClassRegistry::init(), example:
user.test.php
class UserTestCase extends CakeTestCase
{
public $User = null;
public $fixtures = array('app.user', 'app.user_group');
public function start()
{
parent::start();
Configure::write('debug', 2);
}
public function end()
{
parent::end();
}
public function startTest($method)
{
$this->User = ClassRegistry::init('User');
$this->User->query("-- >>>>>>>>>>>>>>>>>>>>>> STARTING TEST: " .
$method . " <<<<<<<<<<<<<<<<<<<<<<<<");
}
public function endTest($method)
{
}
public function testHashPassword()
{
$this->assertEqual($this->User->hashPassword('foo'), 'bar');
}
}
In this example, the user model is associated with the user_group
model (user belongsTo user_group, user_group hasMany user). Tests are
failing with "Error: Database table user_groups for model UserGroup
was not found." in this case. CakePHP first does a 'DESCRIBE `users`' on
'default' connection which works fine. After that, CakePHP tries to do
'DESCRIBE `user_groups` but with 'test_suite' connection. CakePHP should
use 'default' connection here, too.
The described setup worked fine until revision 7869. As of revision 7870
tests are
failing.
--
Ticket URL: <https://trac.cakephp.org/ticket/5877>
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
-~----------~----~----~----~------~----~------~--~---