Blog demo unit tests failures

I am trying to run blog demo unit tests and get following errors:




PHPUnit 3.4.9 by Sebastian Bergmann.


EE....


Time: 1 second, Memory: 9.75Mb


There were 2 errors:


1) CommentTest::testFindRecentComments

Exception: Unknown property 'posts' for class 'CommentTest'.


W:\home\yii-1.1.0.r1700\framework\test\CDbTestCase.php:61

W:\home\yiiblog\www\protected\tests\unit\CommentTest.php:25


2) CommentTest::testApprove

Exception: Unknown property 'posts' for class 'CommentTest'.


W:\home\yii-1.1.0.r1700\framework\test\CDbTestCase.php:61

W:\home\yiiblog\www\protected\tests\unit\CommentTest.php:44


FAILURES!

Tests: 6, Assertions: 1, Errors: 2.



The problem is because CDbFixtureManager failed to insert fixture data to the tbl_post table.

I checked fixture manager code and found that inside CDbFixtureManager::load method there are two calls:




public function load($fixtures)

{

    ...

    $this->resetTable($tableName);

    $rows=$this->loadFixture($tableName);

    ...

}



Table name here is ‘{{post}}’ (taken from model). And then both methods (resetTable and loadFixture) are trying to include files like “W:\home\yiiblog\www\protected\tests\fixtures\{{post}}.init.php” and “W:\home\yiiblog\www\protected\tests\fixtures\{{post}}.php”. These files are not exist and no fixture data is loaded into test database.

After I changed all blog demo models to return full table names ("tbl_post" instead of "{{post}}"), I am able to run tests without failures.

I am using mysql with following settings:




main.php        

...

        'db'=>array(

            'connectionString' => 'mysql:host=localhost;dbname=yiiblog',

            'emulatePrepare' => true,

            'username' => 'root',

            'password' => '',

            'charset' => 'utf8',

            'tablePrefix' => 'tbl_',

        ),


test.php

...

            'db'=>array(

                'connectionString' => 'mysql:host=localhost;dbname=yiiblogtest',

                'emulatePrepare' => true,

                'username' => 'root',

                'password' => '',

                'charset' => 'utf8',

                'tablePrefix' => 'tbl_',

            ),




I am not sure whether I missing something or this is a bug in the CDbFixtureManager.

Any suggestions?