Deprecate Assert in favor of Laravel's AssertableJson #338
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.
This PR deprecates the assertion library introduced in #220.
Because we added Inertia's assertions to Laravel's core in laravel/framework#36454, it no longer makes sense to maintain two separate versions of this. While it is true that Inertia pioneerd this assertion library, it has since matured as part of the Laravel framework.
In addition to reducing the maintenance effort for the Inertia team, the Laravel variant (by now) also has more features that users might want, it's properly documented, and has the benefit of automatically inheriting assertion macros that are registered by installed third-party packages.
Differences
Do not worry, the Laravel variant is nearly identical. Here's all the differences:
misses
/missesAll
methods are namedmissing
andmissingAll
insteadcomponent
,url
,version
) are only available on the top-level when using the newAssertableInertia
class, or when using$response->assertInertia(function ($inertia) {
whereType
,whereContains
,each
and the ability to do shorthand-scoping without countingDeprecating
Assert
Right now (Dec 26th, 2021) the
Assert
version is still available, and theAssertableInertia
is only automatically used on Laravel 8.32 or newer, but a deprecation notice/error will be shown during tests.In addition, strict parameter type hints will crash in existing tests. To solve this quickly, you can alias your import: