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

Utility\CaseInsensitiveDictionary: add dedicated unit tests + minor bug fix #558

Merged
merged 2 commits into from
Oct 11, 2021

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 17, 2021

Utility\CaseInsensitiveDictionary: add dedicated unit tests

While this class was largely already tested via "user" classes, this now adds a set of dedicated tests specifically for this class.

Utility\CaseInsensitiveDictionary: minor bug fix

The use of strtolower() on non-string keys, is 1) not necessary and 2) had side-effects when non-string keys were used as those were then cast to string, which with the current set of tests would lead to the false test case overwriting the null test case and potentially "passing null to non-nullable" errors in PHP 8.1.

While this class is intended to be used with requests headers, the class in itself is not limited to this use-case, so should function as per the specifications, independently of the use-case.

Alternatively, a stricter check could be put in place to only allow string keys for the data captured in this class. That would potentially create a bigger breaking change though.

Related to #497

@jrfnl jrfnl added this to the 2.0.0 milestone Sep 17, 2021
@jrfnl jrfnl force-pushed the feature/caseinsensitivedictionary-add-tests branch from 1d37d71 to 2faecbc Compare October 4, 2021 22:40
While this class was largely already tested via "user" classes, this now adds a set of dedicated tests specifically for this class.
@jrfnl jrfnl force-pushed the feature/caseinsensitivedictionary-add-tests branch from 2faecbc to 9adf84c Compare October 4, 2021 22:57
The use of `strtolower()` on non-string keys, is 1) not necessary and 2) had side-effects when non-string keys were used as those were then cast to string, which with the current set of tests would lead to the `false` test case overwritting the `null` test case and potentially "passing null to non-nullable" errors in PHP 8.1.

While this class is intended to be used with requests headers, the class in itself is not limited to this use-case, so should function as per the specifications, independently of the use-case.

Alternatively, a stricter check could be put in place to only allow string keys for the data captured in this class. That would potentially create a bigger breaking change though.
@jrfnl jrfnl force-pushed the feature/caseinsensitivedictionary-add-tests branch from 9adf84c to 0cc1e15 Compare October 4, 2021 23:00
@schlessera schlessera merged commit 4444a11 into develop Oct 11, 2021
@schlessera schlessera deleted the feature/caseinsensitivedictionary-add-tests branch October 11, 2021 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants