Codeception / Codeception/module-rest

seeResponseMatchesJsonType issue on multiple arrays of arrays

未关闭
#91 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
60
派生
30
平均合并
22 小时 37 分钟
30 天内合并 PR
1

描述

#### What are you trying to achieve?
Trying to use seeResponseMatchesJsonType on a response from multiple arrays of arrays

#### What do you get instead?
After several iterations I get an error

```bash
1) testCest: Test Get the SUSPENDED Venues!
Test tests/api/testCest.php:suspendedVenues
Step See response matches json type {"businessHourID":"integer","workingDay":"string","specialHourDate":"string|null","fromTime":"string|null","toTime":"string|null","isClosed":"boolean"},"$..businessHours[22]"
Fail Key `businessHourID` doesn't exist in []
```
> Provide test source code if related
The code I use is
```php
// businessHours array from the venue payload
public static $businessHoursArrayResponse = [
'businessHourID' => 'integer',
'workingDay' => 'string',
'specialHourDate' => 'string|null',
'fromTime' => 'string|null',
'toTime' => 'string|null',
'isClosed' => 'boolean'
];
...
$businessHoursArray = $I->grabDataFromResponseByJsonPath('$..businessHours.*');
for ($i=0; $i < count($businessHoursArray); $i++){
if (!empty($businessHoursArray[$i])) {
$I->seeResponseMatchesJsonType(self::$businessHoursArrayResponse, '$..businessHours['.$i.']');
}
}
```
var_dump($businessHoursArray) prints an array of 53 valid arrays no missing keys or anything.
### Details

* Codeception version: v4.1.20
* PHP Version: 7.2.24
* Operating System: Ubuntu
* Installation type: Phar
* List of installed packages (`composer show`)
* Suite configuration:

```yml
actor: ApiTester
modules:
enabled:
- Asserts
- Helper\Api
- REST:
depends: PhpBrowser
url: '****'
part: Json
curl:
CURLOPT_RETURNTRANSFER: true
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。