Yii функциональное тестирование - PullRequest
0 голосов
/ 25 февраля 2012

Я пытаюсь выполнить функциональное тестирование, как в примере в The Definitive Guide to Yii.

Это мое приспособление в tbl_showcase.php:

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,
    ),
);

Это мой тестовый класс:

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');
    }
}

Я начинаю тест

phpunit functional/ShowcaseTest.php

и получите следующую ошибку:

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.

1 Ответ

1 голос
/ 25 февраля 2012

Вы можете обойти это, явно присвоив name свойство классу ShowcaseTest, например:

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

Или посмотрите сам файл фикстур, где определены свойства.

...