CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

fix: Allow lists on FeatureTestTrait#post $params

Open 3ynm opened this issue 1 year ago • 5 comments

Description**

Fixes a bug that doesn't allow to send lists in JSON format in FeatureTestTrait#post or #call('POST',.... This because it expected params to always be an associative array.

Checklist:

  • [x] Securely signed commits
  • [x] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [x] Unit testing, with >80% coverage
  • [x] User guide updated
  • [x] Conforms to style guide

3ynm avatar Sep 27 '24 01:09 3ynm

You can reproduce the bug by deleting is_string($index) && on line 293 of system/HTTP/RequestTrait.php and then running the tests.

3ynm avatar Sep 27 '24 01:09 3ynm

Thank you for your first contribution!

Can you also add an entry to the changelog, under the section "Bugs Fixed"? If you're unsure how it should look, you can check previous releases.

michalsn avatar Sep 27 '24 06:09 michalsn

Done

3ynm avatar Sep 27 '24 07:09 3ynm

Sorry, now I see that this is about something different than I originally thought - even though you described it correctly from the beginning.

I guess it was too early for me this morning...

This is a bug in FeatureTestTrait class and should be fixed in this file. It seems to me that we should check $this->bodyFormat in the populateGlobals() method when we check the condition for post: https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Test/FeatureTestTrait.php#L382

I'm afraid the proposed changes are not the right ones. But after my slip-up, I will wait for the opinions of others.

michalsn avatar Sep 27 '24 10:09 michalsn

No problem. I just patched it blindly, but surely someone more familiar with the codebase can come up with a better approach.

3ynm avatar Sep 27 '24 15:09 3ynm