-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Unified Test Runner
-
PHP Drivers
-
Not Needed
Matches::assertEquals() relies on PHPUnit's comparators for comparing values within documents. The default comparators defer to PHP's comparison logic, which is too liberal for the flexible numeric comparisons called for by the unified test format. When comparing documents, strings should never be considered equivalent to integers or doubles.
Since SebastianBergmann\Comparator\Factory::getComparatorFor() prefers custom comparators over the PHPUnit defaults, we may be able to work around this by creating another custom comparator (as we did with Int64Comparator) to handle numeric comparisons and reject numeric strings outright. This might have added side effects on the rest of our test suite, but it's unlikely that we'd rely on that behavior – especially since we tend to do strict comparisons (e.g. assertSame()) whenever possible.
Separately, we may want to reconsider whether Int64Comparator should accept string values, as it also defers to is_numeric() and the internal Int64 comparison handler, which does allow strings.
- is related to
-
PHPLIB-1569 Add valid-pass and valid-fail tests for $$matchAsRoot and $$matchAsDocument operators
- Closed
-
DRIVERS-2573 Add valid-pass and valid-fail tests for $$matchAsRoot and $$matchAsDocument operators
- Implementing