Skip to content

Instantly share code, notes, and snippets.

@sergsoares
Last active April 22, 2019 11:42
Show Gist options
  • Select an option

  • Save sergsoares/3ce8f2ba53415dc0d8a4b88a6a6043d5 to your computer and use it in GitHub Desktop.

Select an option

Save sergsoares/3ce8f2ba53415dc0d8a4b88a6a6043d5 to your computer and use it in GitHub Desktop.
Trait to mimic test method [assertJsonStructure](https://laravel.com/docs/5.8/http-tests#assert-json-structure) with Array.
<?php
namespace YOUR_NAME_SPACE;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Http\Response;
trait ArrayAssertTrait
{
public function assertArrayStructure($resultData = null, array $structure = null)
{
return (new TestResponse(new Response))->assertJsonStructure($structure, $resultData);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment