Laravel assertDeleted

05 Dec, 2019 // 1 min read

In a recent pull request authored by @jasonmccreary a new helper method for database testing was proposed to the Laravel framework.

This pull request quickly got merged and is now available in Laravel ^6.6.0.

It works the same way as the existing assertSoftDeleted method, meaning you may pass it a model to assert the record was deleted.

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.

Prior to 6.6.0 it would look something like this;

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

After the changes in 6.6.0 we can now do this instead;


You can review the full changelog here.


~ Robbin

#laravel #tdd