Bug 15505: Mark Hold Items 'On hold' instead of 'Available'
[koha.git] / t / db_dependent / Items.t
index 4744cff..aeb968f 100755 (executable)
@@ -251,7 +251,7 @@ subtest 'GetHiddenItemnumbers tests' => sub {
 
 subtest 'GetItemsInfo tests' => sub {
 
-    plan tests => 7;
+    plan tests => 9;
 
     $schema->storage->txn_begin;
 
@@ -313,6 +313,19 @@ subtest 'GetItemsInfo tests' => sub {
     is( $results[0]->{ restrictedvalueopac }, "Restricted Access OPAC",
         'GetItemsInfo returns a restricted value description (OPAC)' );
 
+    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
+    #place item into holds queue
+    my $dbh = C4::Context->dbh;
+    $dbh->do(q{INSERT INTO tmp_holdsqueue (biblionumber, itemnumber, surname, borrowernumber ) VALUES (?, ?, "Zorro", 42)}, undef, $item_bibnum, $itemnumber);
+    @results = GetItemsInfo( $biblio->biblionumber );
+    is( $results[0]->{ pending_hold }, "1",
+        'Hold marked as pending/unavailable if not AllowItemsOnHoldCheckout' );
+    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
+    @results = GetItemsInfo( $biblio->biblionumber );
+    is( $results[0]->{ pending_hold }, undef,
+        'Hold not marked as pending/unavailable if AllowItemsOnHoldCheckout' );
+
+
     $schema->storage->txn_rollback;
 };