Expected::exactly should have ability to change callback method per times called
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
Hướng nghiên cứu
Bắt đầu bằng cách xác định phần triển khai của Expected::exactly trong repository Codeception Stub và xem lại cách các lần gọi callback hiện đang được xử lý. Sử dụng ví dụ hai callback trong issue làm trường hợp chấp nhận: các lần gọi liên tiếp phải nhận được các phản hồi khác nhau, và một callback phải có thể thực hiện các assertion trước khi trả về.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What are you trying to achieve?
Http client send method is called 2 times on a test
I would like to make different response objects for each of them
on one of them I would also like to have asserts
What do you get instead?
RN it is impossible to have different callbacks for consecutive calls
Provide console output if related. Use
-vvvmode for more details.
Provide test source code if related
$oauth2Provider->setHttpClient($this->construct(Client::class, [], [
'send' => Expected::exactly(2,
function (RequestInterface $request) {
return new Response(200, [
'content-type' => 'application/json'
], '{"access_token": "access", "expires_in": 3600, "refresh_token": "refresh"}');
},
function (RequestInterface $request) {
//assertions go here
return new Response(200, [
], 'response body goes here');
}
]))
]));
Details
- Codeception version:
- PHP Version: 7.4.6
- Operating System: Ubuntu
- Installation type: Composer
- List of installed packages (
composer show) - Suite configuration:
# paste suite config here
Addittional info
RN I do this
$oauth2Provider->setHttpClient($this->construct(Client::class, [], [
'send' => Expected::exactly(2, Closure::fromCallable(new MultiCallable([
function (RequestInterface $request) {
return new Response(200, [
'content-type' => 'application/json'
], '{"access_token": "access", "expires_in": 3600, "refresh_token": "refresh"}');
},
function (RequestInterface $request) {
//asserts go here
return new Response(200, [
], 'response body goes here');
}
])))
]));
<?php
class MultiCallable
{
private $methods;
public function __construct($methods)
{
$this->methods = $methods;
}
public function __invoke(...$args)
{
$method = array_shift($this->methods);
return call_user_func_array($method, $args);
}
}
- Ngôn ngữ chính
- PHP
- Star
- 301
- Fork
- 19
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Codeception/Stub
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
Codeception/Stub#61 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
Codeception/Stub#45 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Codeception/Stub#36 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Codeception/Stub#7 · 5 reaction ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 48/100
Codeception/Stub#31 · 3 bình luận ·
Tất cả issue của Codeception/Stub
Issue tương tự
-
[Bug] : Main navigation "Upcoming Events" link navigates to /events/ without query parameterĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[Area] REST API [Type] Documentation Good First Issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
WordPress/presence-api#584 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100