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
dump(\App\Models\FaqCategory::all());
// or with all the data
dump(DB::table('faq_categories')->get());
$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)
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community