Runnins prove t/db_dependent/Koha/Item.t leads to following error: t/db_dependent/Koha/Item.t .. 13/29 # Looks like you planned 15 tests but ran 5. t/db_dependent/Koha/Item.t .. 15/29 # Failed test 'deletion' # at t/db_dependent/Koha/Item.t line 998. Can't call method "can_edit_items_from" on an undefined value at /home/emmi/Koha/Koha/Item.pm line 298. # Looks like your test exited with 255 just after 15. t/db_dependent/Koha/Item.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 15/29 subtests It seems this happens because we don't mock user enviroment for test patron. However after fixing this issue tests still fail: t/db_dependent/Koha/Item.t .. 14/29 encountered object 'Koha::Library=HASH(0x55f674e55708)', but neither allow_blessed, convert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE method missing) at /home/emmi/Koha/Koha/BackgroundJob.pm line 107. # Looks like you planned 15 tests but ran 5. # Failed test 'deletion' # at t/db_dependent/Koha/Item.t line 999. Can't call method "biblionumber" on an undefined value at /home/emmi/Koha/t/lib/TestBuilder.pm line 193. # Looks like your test exited with 255 just after 15. t/db_dependent/Koha/Item.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 15/29 subtests
Created attachment 152927 [details] [review] Bug 34152: Fix failing t/db_dependent/Koha/Item.t tests This patch fixes following issues in t/db_dependent/Koha/Item.t tests: - "Can't call method "can_edit_items_from" on an undefined value at .../Koha/Item.pm line 298." with sending patron data to mocked environment - "holds tests" test failures due "not_same_branch" errors by mocking IndependentBranches enabled and adding mock user environment To test: 1. Run prove t/db_dependent/Koha/Item.t. => Tests should fail. 2. Apply this patch. 3. Run prove t/db_dependent/Koha/Item.t again. => Success! Sponsored-by: Koha-Suomi Oy
Emmi, Is there something extra that has to be done to make these tests fail? I cannot make them fail.
(In reply to Lucas Gass from comment #2) > Emmi, > > Is there something extra that has to be done to make these tests fail? I > cannot make them fail. There shouldn't be. I'm using current master and without this patch, test fail to that "Can't call method "can_edit_items_from" on an undefined value" error. I also checked my database, there shouldn't be anything there causing this (extra constraint etc.). This could be a case of randomly failing tests, but running prove t/db_dependent/Koha/Item.t consistently fails on my environment. So that might not be the reason.
Oddly enough, I also can't get it to fail. I ran it 5 times and it passed every time. This is especially weird since tests were failing for me and Lucas on Bug 12133, but it wasn't initially failing for you
(In reply to Sam Lau from comment #4) > Oddly enough, I also can't get it to fail. I ran it 5 times and it passed > every time. This is especially weird since tests were failing for me and > Lucas on Bug 12133, but it wasn't initially failing for you I actually managed to "can_edit_items_from" problem by changing one of my test borrowers borrowernumber to 51 (which is the borrowernumber of mock patron created with sub mock_userenv). I also had to set him as superlibrarian to prevent "holds tests" from failing. Could it be that sub mock_userenv doesn't work properly?
Like the other earlier comments, the tests pass for me using koha-testing-docker (KTD) before trying to apply the patch. (The patch still applies successfully). I've changed the status to Failed QA - happy to retest if you could identify what settings/changes to make to get it to fail.
Tests no longer fail. Setting status as "RESOLVED INVALID".