Codeception / Codeception/Stub

Expected::exactly should have ability to change callback method per times called

Đang mở
#30 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
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

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 `-vvv` mode for more details.

> Provide test source code if related

```php
$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:

```yml
# paste suite config here
```
Addittional info
RN I do this
```php
$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
methods = $methods;
}

public function __invoke(...$args)
{
$method = array_shift($this->methods);

return call_user_func_array($method, $args);
}
}
```

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

Hướng nghiên cứu

Start by locating the implementation of Expected::exactly in the Codeception Stub repository and review how callback invocations are currently handled. Use the issue's two-callback example as the acceptance case: consecutive calls should receive different responses, and a callback should be able to perform assertions before returning.

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

Đánh giá

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

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.