Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[JSON:API] add tests for type, included merge and id in attributes#57589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
donnysim wants to merge7 commits intolaravel:json-api-resource
base:json-api-resource
Choose a base branch
Loading
fromdonnysim:json-api-resource

Conversation

@donnysim
Copy link
Contributor

@donnysimdonnysim commentedOct 30, 2025
edited
Loading

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
ContributorAuthor

@crynobone 🙏

@crynobonecrynobone self-assigned thisOct 31, 2025

publicfunctiontestResourceTypeIsPickedFromMorph()
{
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
ContributorAuthor

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>
@crynobonecrynobone changed the titleadd tests for type, included merge and id in attributes[JSON:API] add tests for type, included merge and id in attributesOct 31, 2025
@taylorotwelltaylorotwell marked this pull request as draftOctober 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) needsid,name, andemail values to be available, but the relationship only loads partial values.

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

Reviewers

@crynobonecrynobonecrynobone left review comments

@timacdonaldtimacdonaldAwaiting requested review from timacdonald

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@donnysim@crynobone@timacdonald

[8]ページ先頭

©2009-2025 Movatter.jp