Is it possible to type-check the root?

Đang mở
#14 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php
Lĩnh vực
api, testing-qa

Hướng nghiên cứu

Bắt đầu bằng cách đọc bộ kiểm tra JsonType và các assertion hiện có cho response REST. Xác định entry point được đề xuất seeJsonResponseLengthIs(int $number) cho một response có root là mảng được đánh chỉ mục, sau đó bổ sung coverage cho thấy nó xác thực số lượng phần tử của response và từ chối các root không phải là mảng được đánh chỉ mục.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
60
Fork
30
Merge trung bình
22 giờ 37 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Codeception/module-rest

Tất cả issue của Codeception/module-rest

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.