You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing database assertions with assertDatabaseHas(), JSON fields like variables may cause failures if the attribute is not explicitly cast in the model.
Issue:
Laravel stores JSON as a string, leading to double-encoded values.
This causes assertDatabaseHas() to fail because it expects an exact match.
Steps to Reproduce
Run php artisan test.
The test fails because the JSON field is stored as a string but asserted as an object.
Expected Behavior:
The test should pass because the inserted record matches the expected values, including JSON fields.
Actual Behavior:
The test fails because Laravel stores variables as a string (double-encoded JSON), causing assertDatabaseHas() to look for a mismatched format.
The text was updated successfully, but these errors were encountered:
When testing database assertions with assertDatabaseHas(), JSON fields like variables may cause failures if the attribute is not explicitly cast in the model.
Issue:
Laravel stores JSON as a string, leading to double-encoded values.
This causes assertDatabaseHas() to fail because it expects an exact match.
Steps to Reproduce
Run php artisan test.
The test fails because the JSON field is stored as a string but asserted as an object.
Expected Behavior:
The test should pass because the inserted record matches the expected values, including JSON fields.
Actual Behavior:
The test fails because Laravel stores variables as a string (double-encoded JSON), causing assertDatabaseHas() to look for a mismatched format.
The text was updated successfully, but these errors were encountered: