Summer Sale! All accounts are 50% off this week.

Fiton012's avatar

Emulate database connection error on phpunit

In order to handle the database error connection during a database interaction using eloquent I am using a try - catch statement.

Now I want to turn off the database in one of my phpunit tests to test that behavior. How can I do that?

0 likes
2 replies
Chris_Ruskai's avatar

@fylzero There is a lot of need. If your application fails gracefully, you need to mock the exception to achieve 100% code coverage.

Please or to participate in this conversation.