I have followed the book Agile Web Application Development with Yii 1.1 and PHP5, and made the examples in a similar way like was described in the book, but applying to my own design.
All went ok until chapter 5 page 91. I got the error well known running the script CommerceTest, similar to ProjectTest but applied to my site:
There was 1 error:
- CommerceTest::testRead
Exception: Unknown method ‘commerces’ for class ‘CommerceTest’.
/xdir/yii/framework/test/CDbTestCase.php:78
/xdir/protected/tests/unit/CommerceTest.php:44
/xdir/protected/tests/unit/CommerceTest.php:44
In CommerceTest appears:
<?php
class CommerceTest extends CDbTestCase
{
public $fixtures=array
(
'commerces'=>'Commerce',
);
...
public function testRead()
{
$retrievedProject = $this->commerces('commerce1'); // <--- line 44
$this->assertTrue($retrievedProject instanceof Commerce);
$this->assertEquals('Test commerce 1',$retrievedProject->name);
}
I have searched all the web looking for the answer, and I tried everything, but nothing worked. The last try I did was to run the script with debug in netbeans, and I could get the answer, at least for me it worked.
In the fixtures dir, I just changed the name from “commerce.php” to “dbname.commerce.php” , and that’s it, the test ran ok.
The only question is why worked or why is not well documented in the book.
thanks for your answers.