Support the ongoing development of →
posted 5 years ago
Last updated 2 years ago.

Doe the FaqCategory has the SoftDeletes trait? Then it exist in the database but with the deleted_at filled.

You can fix the assert with adding that field:

$this->assertDatabaseMissing('faq_categories', ['id' => 1, 'deleted_at' => null]);

It does not. I know about softDeletes. I think that there is some kind of cacheing, and assertDatabaseMissing actually do not check database, but it gets a data from cache, but it is tight theory.


I now just see that you don't use the id in the assert. And you can for debugging dump what is inside the table.

// with the model
// or with all the data
$this->assertDatabaseMissing('faq_categories', ['id' => $fc->id, 'deleted_at' => null]);

That is the way I sometimes debug why I didn't get what I want (and most of the time it was a simple mistake from my side)

Last updated 5 years ago.

Yeah, i tried lots of things, i put there 1 becouse i was out of ideas. Of course i started from code with $fc->id in assertion, still the same issue. I am using RefreshDatabase trait so "1" is no problem here.

EDIT: I figured it out. I am using model binding in my controllers, so i can not just put $this->withoutMiddleware() in test, becouse route model binding will not work (something needs to be done in middlewares). In addition looks like laravel caches config, so before test i have to run artisan cach:clear. VerifyCsrf middleware is disabled in test env.

Last updated 5 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.