Skip to content

Commit

Permalink
Fix/contact test (#1353)
Browse files Browse the repository at this point in the history
* fix ContactTest.php which is often failing

* compare string representation

* remove redundant function and only

---------

Co-authored-by: herpaderpaldent <herpaderpaldent@users.noreply.github.com>
  • Loading branch information
herpaderpaldent and herpaderpaldent authored Mar 23, 2023
1 parent 4ab1dfe commit e0ef17f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/Integration/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@
->has(
'data.0',
fn (AssertableJson $json) =>
$json->where('corporation_standing', json_decode(json_encode($corp_standing, JSON_NUMERIC_CHECK), null, 512, JSON_NUMERIC_CHECK))
// Here we have a problem. The $corp_standing is a float, but in the json it is a string.
// the json_encode is storing decimal values as string.
// The json_decode is not converting the string to a float if the value is not decimal, but an integer.
// hence we convert the value and the expected value to a string with fix precision and compare them.
$json->where('corporation_standing', fn ($standing) => number_format($standing, 2) === number_format($corp_standing, 2))
->where('standing', fn ($standing) => number_format($standing, 2) === number_format(10, 2))
->etc()
->etc()
)
->etc()
Expand Down

0 comments on commit e0ef17f

Please sign in to comment.