userfrosting / fortress

A schema-driven system for elegant whitelisting, transformation and validation of user input on both the client and server sides from a unified set of rules.
Other
25 stars 9 forks source link

Implement some unit tests #19

Closed alexweissman closed 7 years ago

alexweissman commented 7 years ago

We desperately need some unit tests for this module. Does phpunit support a way to mock JSON objects?

lcharette commented 7 years ago

Yes it does: https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertJsonStringEqualsJsonString

alexweissman commented 7 years ago

There's gonna be a lot of test cases to write 😓

alexweissman commented 7 years ago

Alright, the deed is done. I'm testing the output of JqueryValidationAdapter directly as a PHP array, because I am assuming that PHP's json_encode function works properly. In fact, UserFrosting doesn't even bother converting to JSON in the controller anyway - we pretty much always handle that in Twig templates.

I'm not bothering to write tests for FormValidationAdapter, because I doubt anyone is actually using the FormValidation plugin anyway.