Let me try to reiterate. The "mock" testing strategy would mean preparing three different mock objects, one failing each particular call you want to handle failure of and succeeding others. First you would set
connect() to fail, run your code and check whether the error handling subroutines are called. Then you would restore normal behaviour of
connect() (see also:
DBD::Mock to allow testing database error handling without a live database) but set
prepare to fail and run your code again. Lather, rinse, repeat until all error conditions you want to be able to handle are tested.