Functional testing

I try to do functional test like to example into The Definitive Guide to Yii.

This is my fixture:


return array(

    'sample1'=>array(

        'title'=>'Welcome',

        'content'=>'A main page test',

        'row_type'=>1,

    ),

    'sample2'=>array(

        'title'=>'About',

        'content'=>'An about page test'

        'row_type'=>2,

    ),

);



This is my test class:


class ShowcaseTest extends WebTestCase

{

    public $fixtures = array('showcase'=>'Showcase');


    public function testIndex()

    {

        $this->open('/');


        $this->assertTextPresent($this['showcase']['sample1']['title']);

        $this->assertTextPresent('Welcome');


        $this->assertTextPresent($this->showcase['sample1']['content']);

        $this->assertTextPresent('A main page test');

    }

}



I start test


phpunit functional/ShowcaseTest.php

and get an error


Time: 8 seconds, Memory: 6.25Mb


There was 1 error:


1) ShowcaseTest::testIndex

Exception: Unknown property 'name' for class 'ShowcaseTest'.


/home/myfolder/web/yii/framework/test/CWebTestCase.php:48


FAILURES!

Tests: 1, Assertions: 0, Errors: 1.

may be reason is here:

    $this->assertTextPresent([b]$this['showcase'][/b]['sample1']['title']);


    $this->assertTextPresent('Welcome');





    $this->assertTextPresent([b]$this->showcase[/b]['sample1']['content']);


    $this->assertTextPresent('A main page test');

I’ve fixed my test code to


$this->assertTextPresent($this->showcase['sample1']['content']);

$this->assertTextPresent('A main page test');

I still get the error.

it seems yii cannot find your fixture file.

What’s the name of fixture file and in which directory it lies?

A fixture I was place at




myapp/protected/tests/fixtures/Showcase.php



My test code placed at


myapp/protected/tests/functional/ShowcaseTest.php

I renamed the fixture file to "tbl_showcase.php". Launched the parser, which found that in the fixture is missing a comma. So the file fixtures found. I added a comma, but it still got error test.