Restful icon indicating copy to clipboard operation
Restful copied to clipboard

Integration testing: Nette\Application\Request POST data are not handled in InputFactory

Open klimesf opened this issue 9 years ago • 1 comments

When testing presenters, I create a Nette\Application\Request and let the presenter run it. However, this way the ResourcePresenter::input doesn't contain the POST data sent in the request.

I did some research and found that InputFactory parses POST data from Nette\Http\Request, which is fine when using the API via HTTP calls.

I can make a PR, where Nette\Application\Request would get injected into the InputFactory and the POST data would be extracted from it, rather than from Nette\Http\Request. Do you think this would be a good solution?

klimesf avatar Mar 07 '15 10:03 klimesf

The main purpose of Input factory is to actually parse the request body using mapper (according to Content-Type header). The request body may be in various formats (such as JSON). Getting data from Application Request would work for data URL format only.

Possible solution would be to add Input factory interface so you can create your own input factory for tests.

drahak avatar Mar 07 '15 11:03 drahak