[英]$scenario var in functional test error with Yii2 and Codeception
我正在尝试编写功能测试,但出现错误:
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可用?
给您的testMe()
方法参数$I
和$scenario
:
public function($I, $scenario)
{
[...]
}
然后,您无需实例化FunctionalTester()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.