Bug 19945: Add a test proving that using CanBookBeReserved in ILSDI::HoldItem is...
authorAlex Arnaud <alex.arnaud@biblibre.com>
Tue, 18 Sep 2018 12:59:26 +0000 (12:59 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 28 Jan 2019 13:06:28 +0000 (13:06 +0000)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

t/db_dependent/ILSDI_Services.t

index 6891660..049a8f8 100644 (file)
@@ -299,7 +299,7 @@ subtest 'LookupPatron test' => sub {
 
 subtest 'Holds test' => sub {
 
-    plan tests => 3;
+    plan tests => 4;
 
     $schema->storage->txn_begin;
 
@@ -388,5 +388,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;
 };