Bug 34126 - Tests in t/db_dependent/Koha/Patron.t fail due broken FK constraint
Summary: Tests in t/db_dependent/Koha/Patron.t fail due broken FK constraint
Status: CLOSED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Emmi Takkinen
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-27 05:30 UTC by Emmi Takkinen
Modified: 2024-07-04 20:37 UTC (History)
1 user (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 34126: Mock userenv in safe_to_delete() tests (1008 bytes, patch)
2023-06-27 07:04 UTC, Emmi Takkinen
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2023-06-27 05:30:11 UTC
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
Comment 1 Emmi Takkinen 2023-06-27 05:34:15 UTC
It's actually this line which fails:

$patron->account->pay({ amount => 10, debits => [ $debit ] });
Comment 2 Emmi Takkinen 2023-06-27 07:04:11 UTC
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.
Comment 3 Pedro Amorim 2023-08-28 09:20:36 UTC
I'm sorry, I can't reproduce this on master.
prove t/db_dependent/Koha/Patron.t
All tests are passing for me.