0

Relatively new to Codeception and trying to hook it up to Slim 3. Setting up a basic test for a POST request like so:

$I->sendPOST('/user', [
        'details' => [
            'id' => 0,
            'package_id' => 0,
            'order_id' => 0
        ]
    ]);

On the route itself, I am using Slim 3's getParam to get the details that I sent over like so:

$details = $request->getParam('details', []);

Running the test via --debug, I see that the Request has {"details":{"package_id":0,"order_id":0}

However, it seems as if the details from the getParam are returning nothing. I've tried sending them separately outside of details but to no avail.

At this point, wondering if it's a PSR-7 compatibility issue between the details I send via Codeception's sendPOST and Slim 3's getParam since the getParam method from Slim came with the comments:

 * Fetch request parameter value from body or query string (in that order).
 *
 * Note: This method is not part of the PSR-7 standard.

Any help is appreciated!

ejb
  • 1
  • `details` should be available in ParsedBody, is there a method like getParsedBody() in Slim? Please review https://github.com/herloct/codeception-slim-module/blob/1.1.0/src/Lib/Connector/Slim.php#L69-L108 and look what Slim request methods can be used to retrieve that parameter. – Naktibalda Feb 26 '20 at 07:57
  • @Naktibalda hi thanks for the advice. i let the code sit for a day and when i ran the test again the next day it for some reason worked...but your link definitely helped me understand more of what was going on. i appreciate your help! – ejb Mar 02 '20 at 11:20

0 Answers0