我有API测试
public function loginAsRegisteredUser(\ApiTester $I)
{
$I->wantTo('Login as registered user');
$I->sendPOST('/action.php?ap=V4&p=Customer&c=Customer&a=login',['customer' => ['email' => $this->registered_user_email, 'password' => $this->registered_user_password]]);
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
$I->seeResponseIsJson();
$I->seeResponseMatchesJsonType(["customer" => ["id_customer"=> 'string|null',"first_name"=>'string|null',"last_name"=>'string|null',"newsletter"=>'string|null']]);
}
和id_customer字段始终无法进行比较
1) LoginCest: Login as registered user
Test tests/api/LoginCest.php:loginAsRegisteredUser
Step See response matches json type {"customer":{"id_customer":"string|null","first_name":"string|null","last_name":"string|null","newsletter":"string|null"}}
Fail `id_customer: 1` is of type `string|null`
回复示例: { “顾客”:{ “id_customer”:1, “如first_name”: “如”, “姓氏”: “ewq”, “通讯”: “1”}}
我已经尝试了字段id_customer(例如数字)的所有可能类型,但没有人工作。有人现在解决了吗?
答案 0 :(得分:2)
它实际上是在正确验证 - 你的期望是错误的。
预期类型为字符串或null,但实际类型为integer
。