martinszemitis's avatar

Non-http json tests

Hi,

I'm trying to extent https://github.com/spatie/laravel-navigation package for my needs. To be safe I want to also add tests.

This package in general returns resulting navigation as a json tree: app(Navigation::class)->tree();

Laravel has very powerful json assertions ( https://laravel.com/docs/8.x/http-tests#assert-json ) when testing http respose.

Do you have any suggestions how to uses these assertions when testing json returning (non-http response) method?

0 likes
3 replies
martinszemitis's avatar

Thanks, @sinnbeck. But I just now recognized that I'm writing test for laravel package and Laravel framework is not awailable there :( I have to use phpUnit assertions or add the framework to packege - what seems wrong.

But provided links could be useful for me and other later - when trying to test json whish is not part of http response.

Please or to participate in this conversation.