From ee172a94821bce59bd4a4aa82ee64950b09a832b Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Tue, 18 Sep 2018 12:59:26 +0000 Subject: [PATCH] Bug 19945: Add a test proving that using CanBookBeReserved in ILSDI::HoldItem is wrong. --- t/db_dependent/ILSDI_Services.t | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 06d25f6..a812772 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -291,7 +291,7 @@ subtest 'LookupPatron test' => sub { subtest 'Holds test' => sub { - plan tests => 3; + plan tests => 4; $schema->storage->txn_begin; @@ -380,5 +380,51 @@ subtest 'Holds test' => sub { $reply = C4::ILSDI::Services::HoldItem( $query ); is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); + my $biblio3 = $builder->build({ + source => 'Biblio', + }); + + my $biblioitems3 = $builder->build({ + source => 'Biblioitem', + value => { + biblionumber => $biblio3->{biblionumber}, + } + }); + + # Adding a holdable item to biblio 3. + my $item3 = $builder->build({ + source => 'Item', + value => { + biblionumber => $biblio3->{biblionumber}, + damaged => 0, + } + }); + + my $item4 = $builder->build({ + source => 'Item', + value => { + biblionumber => $biblio3->{biblionumber}, + damaged => 1, + } + }); + + my $issuingrule2 = $builder->build({ + source => 'Issuingrule', + value => { + categorycode => $patron->{categorycode}, + itemtype => $item3->{itype}, + branchcode => $patron->{branchcode}, + reservesallowed => 10, + } + }); + + $query = new CGI; + $query->param( 'patron_id', $patron->{borrowernumber}); + $query->param( 'bib_id', $biblio3->{biblionumber}); + $query->param( 'item_id', $item4->{itemnumber}); + + $reply = C4::ILSDI::Services::HoldItem( $query ); + is( $reply->{code}, 'damaged', "Item is damaged" ); + $schema->storage->txn_rollback; }; -- 2.7.4