-
Notifications
You must be signed in to change notification settings - Fork 14
[263]: fix ModelTestState to support custom Eloquent casts over JSON columns
#265
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DenTray
merged 47 commits into
master
from
263-fix-model-test-state-to-support-custom-eloquent-casts-over-json-columns
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
22c9d7f
feat: extend ModelTestState class to differentiate between native JSO…
vitgrams 2c0f541
test: update JSONCustomCast with more complex structure to check cast…
vitgrams 240637a
test: add test cases to check native/custom JSON casts
vitgrams 0356a54
test: minor renaming for better clarity
vitgrams 075f157
test: fix broken tests
vitgrams d64496a
refactor: remove unused arg
vitgrams 6b1b92a
fix: pass model instance to casts get() method to prevent incompatibl…
vitgrams 19b6717
fix: use setRawAttributes() to fill model before cast to ignore mutators
vitgrams f3f6048
test: add test case for casts using another model attribute
vitgrams 0b09513
refactor: separate cast testing concerns into dedicated TestModelWith…
vitgrams 3af9add
test: fix broken test fixture after rebase on master
vitgrams 4422f48
fix: merge original record into partial updates before applying custo…
vitgrams a93a96b
fix: run custom casts before native JSON decoding to preserve raw att…
vitgrams 42de2c8
test: rename test and mocks for better clarity
vitgrams 289c6b7
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
yburlakov 6813e61
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
DenTray 1d247d5
feat: support parameterized custom casts
vitgrams 28d4337
refactor: adjust methods order, args naming
vitgrams 3a99466
refactor: extract model instance as class property
vitgrams f94fc40
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
yburlakov 28ee396
refactor: minor refactoring changes
vitgrams b02d347
feat: support Castable interface in custom cast resolution
vitgrams 095e3e1
test: improve cast mocks naming
vitgrams 88d2de3
feat: support other cast types - primitives, castables and etc
vitgrams 0b16c8e
test: improve tests - model mocks/casts
vitgrams a280046
refactor: remove redundant code
vitgrams 1d2ac74
test: consolidate common tests with data provider
vitgrams 0c21109
test: make model mocks more targetable
vitgrams 5403811
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
DenTray d753cc4
Apply suggestion from @DenTray
DenTray cdc6d97
Apply suggestion from @DenTray
DenTray e56fb4f
fix: clone model instance in applyCasts to avoid shared mutable state
DenTray af43832
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
DenTray 3408629
feat: decode only JSON-casted fields in fixtures; keep all other cast…
vitgrams 8733454
feat: decode native JSON casts by definition, class casts if JSON-backed
vitgrams 120127f
refactor: minor refactoring
vitgrams 0f4ed1d
refactor: minor refactoring changes
vitgrams 029980a
refactor: move common filter logic to getCastFieldsMatching
vitgrams 2232ded
feat: decode JSON cast fields via json_decode instead of getAttribute
vitgrams 2fc683c
fix: adjust casts to property to support laravel-11
vitgrams 1d6ca46
refactor: fix code style
vitgrams d6523be
feat: decode class-cast JSON fields to arrays when preparing fixture …
vitgrams 38c1dbd
test: cover non-json custom cast case with test
vitgrams 6cfa25a
Merge branch 'master' into 263-fix-model-test-state-to-support-custom…
DenTray 08f0169
fix: support cast definitions given as instances in ModelTestState
DenTray 069eca0
fix: declare the mock cast instance as Stringable
DenTray 3c36461
refactor: rename getCastFieldsMatching to getFilteredCasts
DenTray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 3 additions & 13 deletions
16
tests/fixtures/ModelTestStateTest/changes_equals_fixture_primary_key/changed_dataset.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping the
TestModelcase removed the only coverage where a nativearraycast, aCastsAttributescast and aCastablecast coexist on one model — the exact scenario #263 is about.Fixed on the branch:
mixed native, custom and castable castsdata set restored, together withchanges_equals_fixture/*anddb_changes/test_models/assertion_fixture.json. The fixtures also pin that a non-JSON value under a class cast stays a raw string.