CodeIgniter Forums
Testing JSON/XML requests with Feature Tests - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Testing JSON/XML requests with Feature Tests (/showthread.php?tid=77683)



Testing JSON/XML requests with Feature Tests - Derek - 10-04-2020

Currently, when creating an API that is expecting to receive a JSON or XML request body, the Feature Test functionality doesn't work because the body of the request is never set. I would request that we find a way to be able to use Feature Tests when the controller is using the $request->getJson() or $request->getBody() methods to get the request body for use in an API.

I have a solution for this and have created a PR at https://github.com/codeigniter4/CodeIgniter4/pull/3725.