Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自动化yii2中的codeception测试_Php_Testing_Yii2_Codeception - Fatal编程技术网

Php 自动化yii2中的codeception测试

Php 自动化yii2中的codeception测试,php,testing,yii2,codeception,Php,Testing,Yii2,Codeception,我想在yii2中自动化功能codeception测试,我能够使用以下代码测试登录API use tests\codeception\backend\FunctionalTester; $I = new FunctionalTester($scenario); $I->wantTo('Check when authenticated'); $I->sendPOST('/login', ['password' => '11111111', 'email'=>'check@ch

我想在yii2中自动化功能codeception测试,我能够使用以下代码测试登录API

use tests\codeception\backend\FunctionalTester;
$I = new FunctionalTester($scenario);
$I->wantTo('Check when authenticated');
$I->sendPOST('/login', ['password' => '11111111', 'email'=>'check@check.com']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"result"');
$I->seeResponseContains('"message"');
$I->haveHttpHeader('Accept','application/json');
$I->seeResponseContains('"message":"OK"');

在登录API中,我返回可用于进一步处理的auth_令牌,因此我应该将登录API的结果保存在哪里,并将其用于测试进一步API。我们可以使用以下函数存储响应。并进一步检查API

$check = $I->grabResponse();
$check = json_decode($check,true);

将其存储在Page对象的静态属性中,该属性可用于测试API的