Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow lists on FeatureTestTrait#post $params #9204

Closed
wants to merge 2 commits into from

Conversation

3ynm
Copy link

@3ynm 3ynm commented Sep 27, 2024

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:

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

@3ynm
Copy link
Author

3ynm commented Sep 27, 2024

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

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 27, 2024
@michalsn
Copy link
Member

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.

@3ynm
Copy link
Author

3ynm commented Sep 27, 2024

Done

@3ynm 3ynm force-pushed the develop branch 2 times, most recently from d58a30a to e40ef7e Compare September 27, 2024 07:40
Comment on lines +33 to +34
**FeatureTestTrait:** Allows `#call` and `#post` to process JSON lists. It failed because `RequestTrait#fetchGlobal` expected the second parameter ($index) to be an associative array.

This comment was marked as outdated.

@michalsn
Copy link
Member

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.

@3ynm
Copy link
Author

3ynm commented Sep 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants