Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created August 7, 2018 22:46
Show Gist options
  • Save whoisryosuke/455ff79d334ba3338dc1f711da5e4e6a to your computer and use it in GitHub Desktop.
Save whoisryosuke/455ff79d334ba3338dc1f711da5e4e6a to your computer and use it in GitHub Desktop.
Laravel - Testing / API - Assert JSON structure (instead of values)
<?php
$response
->assertStatus(201)
->assertJsonStructure([
'data' => [
'id',
'business_id',
'user_id',
'verified',
'user_type',
'permissions',
'created_at',
'updated_at',
],
]);
// {
// data: {
// {
// id: "013b6658-3f49-40a9-b00c-f400c2fcdbd1",
// business_id: "4f0b5490-5b2c-11e8-b786-0905d3befa8e",
// user_id: "ed73dde3-25b6-4247-899c-c6862549b0dc",
// verified: 1,
// user_type: "representative",
// permissions: "[]",
// created_at: {
// date: "2018-08-07 21:04:24.000000",
// timezone_type: 3,
// timezone: "UTC"
// },
// updated_at: {
// date: "2018-08-07 21:04:24.000000",
// timezone_type: 3,
// timezone: "UTC"
// },
// },
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment