【发布时间】:2015-05-25 04:49:29
【问题描述】:
我正在尝试编写功能测试,但出现错误:
PHPUnit_Framework_Exception: Undefined variable: scenario
我的测试如下所示:
<?php
use tests\functional;
class AccountTest extends \Codeception\TestCase\Test
{
/**
* @var \FunctionalTester
*/
protected $tester;
protected $url = 'http://domain.api/v1/api';
// tests
public function testMe()
{
$I = new FunctionalTester($scenario);
$I->haveHttpHeader('Content-Type', 'application/json'); //remove
$I->haveHttpHeader('Accept', 'application/json'); //remove
$I->sendPost('/account/register');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
}
}
我需要添加什么才能使 $scenario 可用?
【问题讨论】:
-
好的,当我通过运行 "codecept generate:cept functional account/Account" 创建测试时,我更进一步。但是,我无法使用大多数方法,例如 sendPost()。
-
你运行
codecept build了吗?查看advanced application template 提供的测试
标签: php testing yii yii2 codeception