Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
iiii90854yI would argue that `assertJson` is a bad name in the first place and should not be used at all. It's ambiguous and provides no information about what exactly it checks.
-
noyb3894yWhats your expected value then? Again the shit should give true or false back but if you put your other json as expected and it evaluates to true then this is rather the fault of a string evaluating to a boolean?
-
@noyb My entire mistake was falsely using `assertJson` over the correct `assertJsonStringEqualsJsonString` to begin with.
There is no evaluation going on.
`assertJson` will succeed if the first argument is a valid json (and as I pass in my $expected that is always a valid json it will always be true) and the second one is then merely the message phpunit would print if an error was to occur which was my actual JSON payload to test against.
Related Rants
Why is my test not failing? The actual and the expected json is completely different? What the fuck!?!
It says:
static::assertJson($expected, $actual);
right there.
Oh wait.
Nevermind.
`static::assertJson` only checks for any VALID json string that I always provided in with my own expectation m)
Use `assertJsonStringEqualsJsonString` instead.
What.
Who needs meaningful defaults.
(I would claim that `assertJson` should be defaulft for string equalness, and assertValidJson should be for any Json validation. But you are free to disagree.)
rant
phpunit
php
til
tdd
the test that always succeeds