Koha/Patron.t tests fail when apparently when patron should be deleted after paying accountlines: t/db_dependent/Koha/Patron.t .. 10/24 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kv`.`accountlines`, CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE) at /home/emmi/Koha/Koha/Object.pm line 170 # Looks like you planned 14 tests but ran 12. # Failed test 'safe_to_delete() tests' # at t/db_dependent/Koha/Patron.t line 1124. Broken FK constraint# Looks like your test exited with 255 just after 14. t/db_dependent/Koha/Patron.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 11/24 subtests Test Summary Report ------------------- t/db_dependent/Koha/Patron.t (Wstat: 65280 Tests: 14 Failed: 1) Failed test: 14 Non-zero exit status: 255 Parse errors: Bad plan. You planned 24 tests but ran 14. Files=1, Tests=14, 8 wallclock secs ( 0.05 usr 0.00 sys + 7.20 cusr 0.57 csys = 7.82 CPU) Result: FAIL
It's actually this line which fails: $patron->account->pay({ amount => 10, debits => [ $debit ] });
Created attachment 152705 [details] [review] Bug 34126: Mock userenv in safe_to_delete() tests Koha/Patron.t tests failed due broken FK constraint error. Mocking userenv fixes this. To test prove t/db_dependent/Koha/Patron.t.
I'm sorry, I can't reproduce this on master. prove t/db_dependent/Koha/Patron.t All tests are passing for me.