following book Agile Web Application Development fixtures issue

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:

  1. CommerceTest::testRead

Exception: Unknown method ‘commerces’ for class ‘CommerceTest’.




In CommerceTest appears:


class CommerceTest extends CDbTestCase


public &#036;fixtures=array





public function testRead()


	&#036;retrievedProject = &#036;this-&gt;commerces('commerce1');     // &lt;--- line 44

	&#036;this-&gt;assertTrue(&#036;retrievedProject instanceof Commerce);

	&#036;this-&gt;assertEquals('Test commerce 1',&#036;retrievedProject-&gt;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.

If you’d var_dump($this->commerces), you’d see it’s an array (you return array() in relevant file).

Thus, you need to use square brackets to reach it’s values, e.g.


Otherwise it looks like you’re trying to call a method commerces().