6 months ago

SQLite foreign key dont set null on delete in phpunit test

Posted 6 months ago by keizah


I have migration where I add foreign key to threads table ( Problem is that in phpunit test sqlite don't set foreign key null on delete.

1) Tests\Feature\BestReplyTest::if_a_best_reply_is_deleted_then_the_thread_is_properly_updated_to_reflect_that
Failed asserting that '1' is null.

For temporary solution I do it manually - I am using model static::deleted and then test is passing.

Where is the problem? Jeffrey covered this topic in but his solution doesn't help me. I'm using Laravel 7.3 and foreign_key_constraints is true by default.

Please sign in or create an account to participate in this conversation.