我想知道是否可以通过方法JsonType
为验证 API 响应定义一些自定义。seeResponseMatchesJsonType
我的意思是,假设我有一个结构的响应:
[
'id' => 'integer',
'name' => 'string',
'address' => [
'street' => 'string',
'city' => 'string'
]
]
显然这个结构address
嵌入了复杂的类型,并且在整个应用程序中这种类型可能会被多次使用,所以我想简单地写:
$I->seeResponseMatchesJsonType([
'id' => 'integer',
'name' => 'string',
'address' => 'addressType'
]);
无需一直重写这个嵌入式结构。如何在 Codeception 中实现它?