Created attachment 19985 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.pm t/db_dependent/RotatingCollections.pm .. 1/41 attempting to use non-existent class sorting routine Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. t/db_dependent/RotatingCollections.pm .. ok All tests successful. Files=1, Tests=41, 2 wallclock secs ( 0.04 usr 0.02 sys + 0.99 cusr 0.08 csys = 1.13 CPU) Result: PASS
Created attachment 19986 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. 1/41 attempting to use non-existent class sorting routine Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 2 wallclock secs ( 0.04 usr 0.02 sys + 0.99 cusr 0.08 csys = 1.13 CPU) Result: PASS
t/db_dependent/RotatingCollections.t .. 1/41 DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/RotatingCollections.t line 41. DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/RotatingCollections.t line 41. Is my db out of sync?
(In reply to Srdjan Jankovic from comment #3) > t/db_dependent/RotatingCollections.t .. 1/41 DBD::mysql::db do failed: > Cannot delete or update a parent row: a foreign key constraint fails > (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) > REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at > t/db_dependent/RotatingCollections.t line 41. > DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign > key constraint fails (`koha`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN > KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE > CASCADE) at t/db_dependent/RotatingCollections.t line 41. > > Is my db out of sync? I just try and indeed if i just do prove t/db_dependent/RotatingCollections.t , i have the same errors. But if i'm in root or if i do sudo prove t/db_dependent/RotatingCollections.t, it works! I really don't understand why. I'll try to fix this problem...
Created attachment 20106 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. 1/41 attempting to use non-existent class sorting routine Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 2 wallclock secs ( 0.04 usr 0.02 sys + 0.99 cusr 0.08 csys = 1.13 CPU) Result: PASS
(In reply to kenza from comment #5) > Created attachment 20106 [details] [review] [review] > Bug 10653: C4::RotatingCollections.pm needs unit tests > > The tests are wrap in a database transaction. > > Test plan: > prove t/db_dependent/RotatingCollections.t > t/db_dependent/RotatingCollections.t .. 1/41 attempting to use non-existent > class sorting routine > Use of uninitialized value $cn_class in concatenation (.) or string at > C4/ClassSortRoutine.pm line 118. > Use of uninitialized value $cn_item in concatenation (.) or string at > C4/ClassSortRoutine.pm line 118. > Use of uninitialized value $cn_class in concatenation (.) or string at > C4/ClassSortRoutine.pm line 118. > Use of uninitialized value $cn_item in concatenation (.) or string at > C4/ClassSortRoutine.pm line 118. > t/db_dependent/RotatingCollections.t .. ok > All tests successful. > Files=1, Tests=41, 2 wallclock secs ( 0.04 usr 0.02 sys + 0.99 cusr 0.08 > csys = 1.13 CPU) > Result: PASS I add the deletion of 'categories' ,'branches' and 'branchcategories'. It should work but it still not: if i do : prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. 1/41 DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`borrowers`, CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) at t/db_dependent/RotatingCollections.t line 41. DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha`.`borrowers`, CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) at t/db_dependent/RotatingCollections.t line 41. # Looks like you planned 41 tests but ran 2. # Looks like your test exited with 255 just after 2. t/db_dependent/RotatingCollections.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 39/41 subtests Test Summary Report ------------------- t/db_dependent/RotatingCollections.t (Wstat: 65280 Tests: 2 Failed: 0) Non-zero exit status: 255 Parse errors: Bad plan. You planned 41 tests but ran 2. Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.34 cusr 0.02 csys = 0.38 CPU) Result: FAIL But if i do: sudo prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. 1/41 attempting to use non-existent class sorting routine Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_class in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. Use of uninitialized value $cn_item in concatenation (.) or string at C4/ClassSortRoutine.pm line 118. t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.37 cusr 0.00 csys = 0.39 CPU) Result: PASS I really don't understand ! So if someone has an idea which can help me...
That's because you have DELETE FROM branches. You can try placing DELETE FROM borrowers before branches, but then you'll have problems with issues. And if you add DELETE FROM issues it will take forever to do that. I think that deleting from base tables is a bad idea. Unlike deleting from specific purpose tables, eg issuingrules, which is ok. I can see that test have progressed in the past couple of years, so this may not be relevant, but what I used to do is either: a) create my own data b) use random existing data, ie SELECT * FROM branches WHERE some_condition ORDER BY random, and take the top one; some_condition is eg has borrowers etc.
Created attachment 20161 [details] Bug 10642 : Inappropriate uses of $sth->finish() in C4::RotatingCollections.pm From the man page finish() Indicate that no more data will be fetched from this statement handle before it is either executed again or destroyed. You almost certainly do not need to call this method. Adding calls to "finish" after loop that fetches all rows is a common mistake, don't do it, it can mask genuine problems like uncaught fetch errors.
Created attachment 20162 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 20 wallclock secs ( 0.02 usr 0.01 sys + 0.41 cusr 0.02 csys = 0.46 CPU) Result: PASS
Created attachment 20201 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 20 wallclock secs ( 0.02 usr 0.01 sys + 0.41 cusr 0.02 csys = 0.46 CPU) Result: PASS Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Created attachment 20424 [details] [review] Bug 10653: C4::RotatingCollections.pm needs unit tests The tests are wrap in a database transaction. Test plan: prove t/db_dependent/RotatingCollections.t t/db_dependent/RotatingCollections.t .. ok All tests successful. Files=1, Tests=41, 20 wallclock secs ( 0.02 usr 0.01 sys + 0.41 cusr 0.02 csys = 0.46 CPU) Result: PASS Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Pushed to master along with a follow-up. Thanks, Kenza!
This patch has been pushed to 3.12.x, will be in 3.12.5. Thanks Kenza!
Pushed to 3.10.x, will be in 3.10.11
Pushed to 3.8.x, will be in 3.8.19.