Is it possible to type-check the root?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- php
- Domain
- api, testing-qa
Research direction
Start by reading the JsonType checker and the existing REST response assertions. Define the proposed seeJsonResponseLengthIs(int $number) entry point around a root indexed-array response, then add coverage showing that it validates the response element count and rejects non-indexed roots.
Written by the indexing model from the issue text.
Description
My main intent is to make sure the response contains the number of elements I expect.
My current flow is to grab the json_decoded response and use PHPUnit asserts for that... but it seems suboptimal.
Then I decided to see the JsonType checker, but even by adding a custom filter (for array/string length) it doesn't really help as I can't type-check the actual root as an array - just its entries.
Unfortunately, the API I'm testing doesn't have a root key (i.e. $.data), the list is directly returned (e.g. [ { user_id: x }, { user_id: y } ]).
I see I can't use the JsonType matcher by design, and changing that could be a breaking change, or an extra argument... Doesn't seem the best?
I wonder if this is such an edge case that I should only care to write something on my own, or if I could submit a PR of something like seeJsonResponseLengthIs(int $number). It would check the response is an indexed array, and then count it.
- Dominant language
- PHP
- Stars
- 60
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Codeception/module-rest
-
Possible way to `grabFullResponse()` or `grabAllHeaders()`?Possibly taken @Azuka claimed this 582 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 38/100
Codeception/module-rest#114 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Codeception/module-rest#110 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
Codeception/module-rest#98 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Codeception/module-rest#79 · 1 comment · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Codeception/module-rest#80 · 2 comments ·
All issues in Codeception/module-rest
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
taskforcesh/bullmq#5238 ·
Maintainers usually reply within 1 day
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itPossibly taken @bfs2021 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/jetpack#55517 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
area/import type/enhancement when/later
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day