Php 自动化yii2中的codeception测试
我想在yii2中自动化功能codeception测试,我能够使用以下代码测试登录APIPhp 自动化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
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的