postJson('/api/v1/bookings/EVB-DOES-NOT-EXIST/cancel') ->assertUnauthorized() ->assertJsonStructure(['message']); }); test('a route model binding miss on an api route gets a 404 JSON envelope', function () { $user = User::factory()->create(); $token = $user->createToken('test')->plainTextToken; $this->withHeader('Authorization', "Bearer {$token}") ->getJson('/api/v1/bookings/EVB-DOES-NOT-EXIST') ->assertNotFound() ->assertJsonStructure(['message']); }); test('an unknown api route gets a 404 JSON envelope, not an HTML page', function () { $this->getJson('/api/v1/this-route-does-not-exist') ->assertNotFound() ->assertJsonStructure(['message']); }); test('an unsupported HTTP method on a known api route gets a 405 JSON envelope', function () { $this->putJson('/api/v1/companies') ->assertStatus(405) ->assertJsonStructure(['message']); });