zenstruck / browser

A fluent interface for your Symfony functional tests.
MIT License
186 stars 17 forks source link

assertJsonMatches may be too strict #70

Closed flohw closed 2 years ago

flohw commented 2 years ago

Hi,

I am still using this lib to recreate my functional tests. I used to use self::assertSame($expectedErrors, $apiErrors) to test if my form errors are the one I expect (I test on api endpoint, not on the symfony type)

When migrating I use the assertJsonMatches('errors', $expectedErrors) method on the browser.

I have a difference between the two assertion methods. The first one (based on phpunit) did not take order in account. The second method (based on zendstruck/assert lib) did it. Which is a bit annoying as I don't care of order of my errors, I only need to know if they are all present.

Is it something I am the only one with this need? Maybe we could change this behavior to have the same as the phpunit's assertSame method?

What do you think?

kbond commented 2 years ago

PHPUnit's assertSame doesn't take array order into account?

flohw commented 2 years ago

Just double checked it again...

It does. And my legacy code uses assertEquals... So I confused and probably didn't check well the first time :roll_eyes:

Closing.

kbond commented 2 years ago

I do think there could be some improvements here. What you describe sounds like a common use case.

Possibly related' https://github.com/zenstruck/browser/issues/35

flohw commented 2 years ago

Yes it might be easier indeed. But not that important to me.

Thanks.