I have the models Task and User
<?
class Task extends AppModel {
        var $name = 'Task';
        var $belongsTo = array ( 'Author' => array (
                                                                                
                'className'     => 'User',
                                                                                
                'conditions'    => '',
                                                                                
                'order' => '',
                                                                                
                'foreignKey'    => 'user_id'
                                                        ));
...
}
?>

<?
class User extends AppModel {
        var $name = 'User';
...
}
?>

Also I`m using fixtures

// user_test_fixture.php
<?php
class UserTestFixture extends CakeTestFixture {
    var $name = 'UserTest';
    var $useTable = 'users';

    var $import = 'User';

        var $records = array(
        array (
                'id' => '1',
                'username' => 'admin',
                'password' => '4fea28c4a708335fbd36db8166edc95c', //admpass
                'fullname' => 'Admin',
                'blocked' => '0',
                'created' => '2007-10-1 10:39:23',
                'updated' => '2007-10-1 10:41:31'
        )
    );
}
?>

// task_test_fixture.php
<?php
class TaskTestFixture extends CakeTestFixture {
    var $name = 'TaskTest';
    var $useTable = 'tasks';
    var $import = 'Task';

    var $records = array(
                array (
                        'id'    => '1',
                        'name'  => 'Project-1',
                        'info'  => 'Prj-1 description',
                        'user_id'       => '1',
                        'parent_id'     => '0',
                        'created'       => '2007-10-26 19:05:52',
                        'modified'      => '2007-10-26 19:05:00',
                        'starttime'     => '0000-00-00 00:00:00',
                        'deadline'      => '2007-11-15 02:57:49',
                        'hours' => '40',
                        'done'  => '0',
                        'hidden'        => '0'
        )
    );
}


And the following I have in my task.test.php

<?
loadModel( 'Task' );

class TaskTest extends Task {
    var $name = 'TaskTest';
    var $useTable = 'tasks';
    var $useDbConfig = 'test_suite';
}

class TaskTestCase extends CakeTestCase {
        var $fixtures = array( 'task_test', 'user_test' );
        var $model = null;

        function testCreate(){
                $this->model =& new TaskTest();
        }


        function testAuthor(){
                $this->model->id = 2;
                $task = $this->model->read();

                $this->assertEqual( $task['Author']['username'], 'admin' );
        }
}


But the test fails because $task['Author'] contains data from working
database, not from the fixture.

How could I fix it?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to