Issue with HTTP Feature Testing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Issue with HTTP Feature Testing (/showthread.php?tid=79307) |
Issue with HTTP Feature Testing - stopz - 05-26-2021 I'll try to be as short with this as i can: so I have a test file with contents: PHP Code: <?php Within the controller i have a simple check right now just to get parsed query string array: PHP Code: <?php Now i run tests via composer run-script test and results are: Quote:Array() // this is the $_GET array. Any ideas what i should try or is there a thing that you see right away that is wrong with my code? Any help Helps! RE: Issue with HTTP Feature Testing - stopz - 05-27-2021 Alright i found an aswer for my own question. I think it has to do with Quote:The $params array does not make sense for every HTTP verb, but is included for consistency. as written in the manual that not all request types support $params. Maybe GET is one of them. But for sake of consistency i wrote my own tiny solution to request endpoints in testing: PHP Code: /** What helped alot is that CodeIgniter actually got my request by: PHP Code: $this->request->getBody(); Hope this helps someone! RE: Issue with HTTP Feature Testing - MGatner - 05-27-2021 Thanks for sharing your solution! Just to add: FeatureTestCase does not necessarily populate the superglobals (like $_GET) nor recreate the full URI. I think you *should* still be able to access the parameters from the Request though - try this instead: PHP Code: public function amethod() |