the test case:
http://bin.cakephp.org/view/1981319085
fixtures:
http://bin.cakephp.org/view/988525363

works like a charm :)
HTH,
Marcin Domanski aka kabturek
http://tumble.kabturek.info

On Jan 11, 4:44 pm, ivlcic <[EMAIL PROTECTED]> wrote:
> Robby, can you share your working code with us, because I am having
> the same problem as sidr.
> I want to "reuse" app model database field definition (the one that
> CakePHP auto resolves from a database) for my tests but with test
> records provided in fixture.
>
> - app model auto filed definition and real data works
> - fixture field definition and fixture record set works
> - app model auto filed definition and fixture record set doesn't work
> (was it ever intended?)
>
> p.s. cake version is 1.2.0-6311 beta
>
> ivl
>
> On Jan 11, 2:33 pm, Robby Anderson <[EMAIL PROTECTED]> wrote:
>
> > I had a beast of a time with fixtures as well, but finally got them to
> > work. Looking at your test model code, try removing the $useTable from
> > the TestTasks declaration. I think that is the line that is forcing
> > the production table instead of the test_suite table.
>
> > On Jan 11, 3:48 am, sidr <[EMAIL PROTECTED]> wrote:
>
> > > 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