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
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

從 seeResponseMatchesJsonType 入口點開始,使用所描述的多個巢狀陣列重現 tests/api/testCest.php:suspendedVenues 中的失敗。追蹤 JSONPath '$..businessHours[i]' 的結果如何被檢查。完成的標準是巢狀陣列中的有效營業時間物件不再產生缺少索引鍵錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
php
領域
api, testing
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。