Yii Framework Forum: Fixtures property issue - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Fixtures property issue

#1 User is offline   Yiiian 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-April 12
  • Location:UK

Posted 02 April 2012 - 05:36 AM

I seem to be having a problem with fixtures in Yii. I have been banging my head against the wall trying to work out why I get no response from phpunit ( no error )

The problem seems to be the following,

public $fixtures=array('projects'=>'Project'); 


The model Project exists and I have the fixtures in a file name tbl_project.php in the fixtures folder of tests and my table name is called tbl_project. Inside the fixtures file is the following.

return array(
        'project1' => array(
            'name' => 'Test Project 1',
            'description' => 'This is test project 1',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
        'project2' => array(
            'name' => 'Test Project 2',
            'description' => 'This is test project 2',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
        'project3' => array(
            'name' => 'Test Project 3',
            'description' => 'This is test project 3',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
    );       


When I run the test case I get the following with no test result information.

PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from ETC/protected/tests/phpunit.xml
If I remove the fixtures array from the top I get the following.

Time: 0 seconds, Memory: 9.25Mb

There was 1 error:

1) ProjectTest::testRead
Exception: Unknown method 'projects' for class 'ProjectTest'. 


Which obviously makes sense. I dont know what Im doing wrong.

Also the fixtures are inserting into the database correctly. It just seems to be dying on public $fixtures and not running any of the tests.
0

#2 User is offline   seb7 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 03-April 12

Posted 03 April 2012 - 04:14 AM

I faced the same prob yesterday my prob was that i used CTestCase instead of CDbTestCase in /protected/tests/ProjectTest.php


View PostYiiian, on 02 April 2012 - 05:36 AM, said:

I seem to be having a problem with fixtures in Yii. I have been banging my head against the wall trying to work out why I get no response from phpunit ( no error )

The problem seems to be the following,

public $fixtures=array('projects'=>'Project'); 


The model Project exists and I have the fixtures in a file name tbl_project.php in the fixtures folder of tests and my table name is called tbl_project. Inside the fixtures file is the following.

return array(
        'project1' => array(
            'name' => 'Test Project 1',
            'description' => 'This is test project 1',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
        'project2' => array(
            'name' => 'Test Project 2',
            'description' => 'This is test project 2',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
        'project3' => array(
            'name' => 'Test Project 3',
            'description' => 'This is test project 3',
            'create_time' => '',
            'create_user_id' => '',
            'update_time' => '',
            'update_user_id' => '',
         ),
    );       


When I run the test case I get the following with no test result information.

PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from ETC/protected/tests/phpunit.xml
If I remove the fixtures array from the top I get the following.

Time: 0 seconds, Memory: 9.25Mb

There was 1 error:

1) ProjectTest::testRead
Exception: Unknown method 'projects' for class 'ProjectTest'. 


Which obviously makes sense. I dont know what Im doing wrong.

Also the fixtures are inserting into the database correctly. It just seems to be dying on public $fixtures and not running any of the tests.

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users