DEF STUDIO srl

Need help with Laravel and web development?

Hire one of our experts for your projects.

We build tailored products, websites and platforms — with care for UX, performance and maintainability.

Booking open for Q4 — limited slots

Models Expectations

toBe() (available from v2, still with v1? Upgrade!)

Assert that the given model has the same ID and belong to the same table of another model.

expect($post)->toBe($anotherPost);

toBeDeleted()

Assert the given model to be deleted.

expect($model)->toBeDeleted();

toBelongTo()

Assert the given model belongs to another one.

expect($post)->toBelongTo($user);

toBeSameModelAs()

Assert that the given model has the same ID and belong to the same table of another model.

expect($post)->toBeSameModelAs($anotherPost);

toBeSoftDeleted()

Assert the given model to be soft deleted.

expect($model)->toBeSoftDeleted();

toExist()

Assert the given model exists in the database.

expect($model)->toExist();

toOwn()

Assert the given model owns child model.

expect($user)->toOwn($post); //<-- HasMany relationship

expect($user)->toOwn($address); //<-- HasOne relationship
Suggest a change
Last updated 22 August 2025