Skip to content
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

[6.x] Add assertDeleted for database testing #30648

merged 1 commit into from Nov 22, 2019


Copy link

jasonmccreary commented Nov 21, 2019

While there are numerous ways to test a record has been deleted, all are relatively lengthy to assert and don't communicate well.


$this->assertDatabaseMissing('posts', [
    'id' => $post->id

There is an assertSoftDeleted which can actually be passed a model. Upon doing so, it conveniently builds the appropriate expectations.

An assertDeleted method is symmetrical with this existing method and improves the developer experience by wrapping all the same behavior of assertDatabaseMissing in an intently named method.


@driesvints driesvints changed the title Add assertDeleted for database testing [6.x] Add assertDeleted for database testing Nov 21, 2019

This comment has been minimized.

Copy link
Contributor Author

jasonmccreary commented Nov 21, 2019

If merged, glad to add a note to the docs about the new method and optionally passing a model argument.

@taylorotwell taylorotwell merged commit 9858507 into laravel:6.x Nov 22, 2019
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed
@jasonmccreary jasonmccreary deleted the jasonmccreary:assert-deleted branch Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.