If we have no patron 51, and we get 51 from Mocks, we have a problem. Easy fix
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_myclone`.`accountlines`, CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE) at /usr/share/koha/Koha/Object.pm line 170 This line is the culprit: $patron->account->pay({ amount => 10, debits => [ $debit ] }); The pay routine gets the manager from userenv. When there is no borrowernumber, Mocks returns 51. And when that does not exist, boom.
Created attachment 156287 [details] [review] Bug 34932: Patron.t - Pass borrowernumber of manager to userenv Test plan: Make sure that you do not have borrowr 51. Run t/db_dependent/Koha/Patron.t. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Trivial: Self SO
Hum ok, certainly enough for now. Maybe we should remove the fallback and force a patron. It will help to catch missing userenv mocks.
Created attachment 156328 [details] [review] Bug 34932: Patron.t - Pass borrowernumber of manager to userenv Test plan: Make sure that you do not have borrowr 51. Run t/db_dependent/Koha/Patron.t. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed to master for 23.11. Nice work everyone, thanks!
Pushed to 23.05.x for 23.05.05
Nice work everyone! Pushed to oldstable for 22.11.x