Koha/t/db_dependent/Circulation
Marcel de Rooy 0fc3f19605 Bug 19004: Adjust AddReturn for retrieving item type
In the regular situation, you can get itemtype via biblio and then
biblioitem as well as via biblioitem (at least when item-level_itypes
is set to biblio).

But since Koha unfortunately defined two relations in item, one for
biblioitemnumber (the good one) and one for biblionumber (redundant),
TestBuilder (correctly) builds one biblioitem and two biblios.

If you item-level_itypes to biblio record, this will result in failing tests
when calling AddReturn (in this case Koha/Patrons.t).
It will crash on:
    Can't call method "itemtype" on an undefined value at C4/Circulation.pm line 1826.
Cause: AddReturn goes via the biblionumber to biblio and than to
biblioitems, and it does not find a biblioitem. (Not a fault from TestBuilder
but a database design problem.)

This patch makes a small change in AddReturn to retrieve the itemtype via
biblioitem. It actually is a shorter road than items->biblio->biblioitems.

Note: I do not test the Biblioitems->find call, since we already checked
the GetItem call before and we have a foreign key constraint.
I did not call $item->effective_itemtype since we still use GetItem; this
could be done later.

Adjusted Circulation/Returns.t too: If we add an item with TestBuilder and
we called AddBiblio before, we should link biblioitemnumber as well.

Test plan:
[1] Do not apply this patch yet.
[2] Set item-level_itypes to biblio record.
[3] Run t/db_dependent/Koha/Patrons.t. (It should fail.)
[4] Apply this patch.
[5] Run t/db_dependent/Koha/Patrons.t again.
[6] Run t/db_dependent/Circulation/Returns.t
[7] Git grep on AddReturn and run a few other tests calling it.
    Note: Bugs 19070/19071 address three tests that call AddReturn too.
[8] In the interface, check in a book.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Note: Bugs 19070 and 19071 are already pushed. The command in comment #4
      has all the tests successful.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-09-01 13:02:27 -03:00
..
IssuingRules Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
Branch.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
CalcDateDue.t Bug 18226 - Remove "use Test::DBIx::Class" instantiations' dangerous code duplication. Replace mock_dbh 2 2017-06-05 17:52:47 -03:00
CalcFine.t Bug 16155: Adjust a few other tests 2016-05-04 13:47:58 +00:00
CheckIfIssuedToPatron.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
CheckValidBarcode.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
dateexpiry.t Bug 11580 - [QA Followup] Remove debug statements 2017-09-01 13:02:23 -03:00
GetHardDueDate.t Bug 16344: Fix test in GetHardDueDate.t 2017-05-24 12:29:43 -03:00
GetPendingOnSiteCheckouts.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
GetTopIssues.t Bug 17829: Move GetMember to Koha::Patron 2017-07-10 13:14:19 -03:00
IsItemIssued.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
issue.t Bug 19071: Fix Circulation/issue.t 2017-08-10 16:25:33 -03:00
MarkIssueReturned.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
NoIssuesChargeGuarantees.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
OfflineOperation.t Bug 12787: Reorganise t/db_dependent files 2016-04-22 00:54:35 +00:00
Returns.t Bug 19004: Adjust AddReturn for retrieving item type 2017-09-01 13:02:27 -03:00
StoreLastBorrower.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
SwitchOnSiteCheckouts.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
TooMany.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00
transfers.t Bug 18292: Remove return 1 statements in tests 2017-08-15 12:17:42 -03:00