The module C4::Members::Attributes.pm is not tested
Created attachment 28919 [details] [review] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm was not tested Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS
Created attachment 28921 [details] [review] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm were not tested. Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS
Created attachment 28922 [details] [review] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm was not tested Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS
DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha_test`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/Members_Attributes.t line 34. DBD::mysql::db do failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha_test`.`issues`, CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON UPDATE CASCADE) at t/db_dependent/Members_Attributes.t line 34. # Looks like you planned 60 tests but ran 1. # Looks like your test exited with 255 just after 1. Fails on a non empty db, (ie if you have any borrowers who have attributes in the database). Do we care about that? Or do we only care that it passes on an empty (or near empty) database?
(In reply to Chris Cormack from comment #4) > Do we care about that? Or do we only care that it passes on an empty (or > near empty) database? Hi Chris, I recommend to Yohann to execute the unit tests with the DB generated by the patch on bug 10337. I have been doing this for 1 year now. All db_dependent tests pass using this DB (except the 3 broken currently).
I feel it would be nice if the unit tests could be run on any db - maybe the patch could be improved a little for the case Chris found?
Looking quickly at this patch, the only dependencies are + categorycode => 'S', + branchcode => 'CPL', This is the case for almost ALL db dependent unit tests. Some tests are very painful to write (for instance, try to write a unit tests in the ACQ module...). It is good not to have to add all data before starting to test something.
However, I think this discussion should have done on bug 10337 (in discussion for 1 year ago).
You are right, that this is not the right place for a general discussion. I was referring to this comment from Chris: >Fails on a non empty db, (ie if you have any borrowers who have attributes in >the database Maybe it would be enough then to add another delete line to make sure there are no other borrowers with patron attributes?
Created attachment 29008 [details] [review] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm were not tested. Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS
Created attachment 29009 [details] [review] Bug 12427: Allow execution of UTs on a DB with issues
(In reply to Katrin Fischer from comment #9) > Maybe it would be enough then to add another delete line to make sure there > are no other borrowers with patron attributes? Agreed, the deletion failed if the DB contains issues. I squashed the 2 first patches and added a follow-up.
Created attachment 29153 [details] [review] [SIGNED-OFF] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm were not tested. Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Test with patrons on db having issues and attributes New test file, all test pass No koha-qa errors
Created attachment 29154 [details] [review] [SIGNED-OFF] Bug 12427: Allow execution of UTs on a DB with issues Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Created attachment 29185 [details] [review] [PASSED QA] Bug 12427: adding unit tests of module C4::Members::Attributes.pm The subroutines UpdateBorrowerAttribute, SearchIdMatchingAttribute, DeleteBorrowerAttribute, GetBorrowerAttributes, GetAttributes, GetBorrowerAttributeValue, SetBorrowerAttributes and CheckUniqueness of the module C4::Members::Attributes.pm were not tested. Test plan: 1/ Execute the command: prove t/db_dependent/Members_Attributes.t 2/ The result has to be: t/db_dependent/Members_Attributes.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.04 usr 0.01 sys + 1.45 cusr 0.08 csys = 1.58 CPU) Result: PASS Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Test with patrons on db having issues and attributes New test file, all test pass No koha-qa errors Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Created attachment 29186 [details] [review] [PASSED QA] Bug 12427: Allow execution of UTs on a DB with issues Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Patches pushed to master. Thanks Yohann
Pushed to 3.16.x for inclusion in 3.16.1.