Skip to content

Add numeric tolerance and JSON matching assertions - #26

Merged
k2gl merged 4 commits into
mainfrom
json-and-numeric-assertions
Sep 9, 2026
Merged

k2gl merged 4 commits into
mainfrom
json-and-numeric-assertions

Conversation

@k2gl

@k2gl k2gl commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Floats and JSON responses were the two things you still had to leave the fluent chain for — decoding a body by hand, or dropping down to assertEqualsWithDelta.

The subset matching turned out to be the interesting part. Reusing the old array helper made list indexes behave like object keys, so containsJson(['items' => [['id' => 2]]]) missed anything that was not the first element. Lists are matched by membership now, and arrayContainsAssociativeArray() moved onto the same rule — which also means an expected null stops passing against a document that has no such key, so tests that were asserting nothing will go red.

k2gl added 4 commits September 9, 2026 22:49
isCloseTo() defaults to PHP_FLOAT_EPSILON: enough for float arithmetic noise,
too small to hide a wrong value.
It is PHP 8.3+, while the package supports 8.1.
Matching by index meant an expected element had to sit first, which missed the
case the assertion exists for. A missing key no longer reads as null either.
arrayContainsAssociativeArray() had the same two bugs; both share SubsetMatcher now.
@k2gl
k2gl force-pushed the json-and-numeric-assertions branch from 728caf6 to c73d183 Compare September 9, 2026 17:52
@k2gl
k2gl merged commit 92c96e6 into main Sep 9, 2026
11 checks passed
@k2gl
k2gl deleted the json-and-numeric-assertions branch September 9, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant