Skip to content

Conversation

@donnysim
Copy link
Contributor

@donnysim donnysim commented Oct 30, 2025

Added failing test to assert that:

  1. Model type is picked from morph map
  2. "included" resources do not contain primary key in attributes
  3. "included" matching resource attributes are merged

I'm unsure how the intended way will be to test the data so picked what I found around other tests.

@donnysim
Copy link
Contributor Author

@crynobone 🙏

@crynobone crynobone self-assigned this Oct 31, 2025

public function testResourceTypeIsPickedFromMorph()
{
Relation::morphMap([JsonApiModel::class => 'json-api-model']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CleanShot 2025-10-31 at 11 57 41@2x

Should it be ['json-api-model' => JsonApiModel::class]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, that's what I get for doing it during work break. Will get back to this in a bit 👍

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@crynobone crynobone changed the title add tests for type, included merge and id in attributes [JSON:API] add tests for type, included merge and id in attributes Oct 31, 2025
@taylorotwell taylorotwell marked this pull request as draft October 31, 2025 16:18
'email' => 'deputy@example.com',
],
], $responseData['included'][0]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timacdonald need your input on this and how it should be affected, especially when the resource (e.g., UserResource) needs id, name, and email values to be available, but the relationship only loads partial values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants