Codeception / Codeception/lib-innerbrowser

[Lib/InnerBrowser] Send raw content in post body

未关闭
#61 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
87
派生
20
PR 合并指标
30 天内没有已合并 PR

描述

#### What are you trying to achieve?
I am trying to call `sendAjaxPostRequest` and I would like to pass raw, unformatted parameters to the server.
For example
```php
$I->sendAjaxPostRequest('/some-endpoint', '{"foo": "bar"}');
// or even
$I->sendAjaxPostRequest('/some-endpoint', 'hello, how do you do?')
```

#### What do you get instead?
I get an error saying that the second parameter of sendAjaxPostRequest must be of type array. This array then gets converted using http_build_query and there is no way to pass raw data. See https://github.com/Codeception/Codeception/blob/3.1/src/Codeception/Lib/InnerBrowser.php#L189

When passing an array, the array always gets converted to http query params format of `foo=bar&example=codeception`

I think an alternative approach could be to use REST Module, which I think can accept raw content (or at least properly json_encode body).

Is there something I am missing? How would you suggest to test this endpoint?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。