Codeception / Codeception/module-rest

seeResponseMatchesJsonType issue on multiple arrays of arrays

Aberta
#91 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
PHP
Estrelas
60
Forks
30
Merge médio
22h 37min
PRs com merge (30d)
1

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece pelo ponto de entrada seeResponseMatchesJsonType e reproduza a falha de tests/api/testCest.php:suspendedVenues usando os múltiplos arrays aninhados descritos. Rastreie como o resultado de JSONPath '$..businessHours[i]' é verificado. O trabalho estará concluído quando objetos válidos de horário de funcionamento em arrays aninhados não produzirem mais um erro de chave ausente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
php
Domínio
api, testing
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.