Bug 10640: (follow-up) bump up the number of expected tests in Bookseller.t
[koha.git] / t / db_dependent / Search.t
index 8f7c523..f786a69 100644 (file)
@@ -12,7 +12,7 @@ use YAML;
 use C4::Debug;
 require C4::Context;
 
-use Test::More tests => 78;
+use Test::More tests => 79;
 use Test::MockModule;
 use MARC::Record;
 use File::Spec;
@@ -64,7 +64,7 @@ $contextmodule->mock('preference', sub {
         return '490av';
     } else {
         warn "The syspref $pref was requested but I don't know what to say; this indicates that the test requires updating"
-            unless $pref =~ m/(XSLT|item|branch|holding|image|insecure)/i;
+            unless $pref =~ m/(XSLT|item|branch|holding|image)/i;
         return 0;
     }
 });
@@ -105,7 +105,7 @@ $contextmodule->mock('marcfromkohafield', sub {
             'items.restricted' => ['952', '5' ],
             'items.stack' => ['952', 'j' ],
             'items.uri' => ['952', 'u' ],
-            'items.wthdrawn' => ['952', '0' ]
+            'items.withdrawn' => ['952', '0' ]
             }
         );
         return \%hash;
@@ -162,12 +162,15 @@ my $dbh = C4::Context->dbh;
 $dbh->{mock_add_resultset} = {
     sql     => 'SHOW COLUMNS FROM items',
     results => [
+        [ 'rows' ], # seems like $sth->rows is getting called
+                    # implicitly, so we need this to make
+                    # DBD::Mock return all of the results
         [ 'itemnumber' ], [ 'biblionumber' ], [ 'biblioitemnumber' ],
         [ 'barcode' ], [ 'dateaccessioned' ], [ 'booksellerid' ],
         [ 'homebranch' ], [ 'price' ], [ 'replacementprice' ],
         [ 'replacementpricedate' ], [ 'datelastborrowed' ], [ 'datelastseen' ],
         [ 'stack' ], [ 'notforloan' ], [ 'damaged' ],
-        [ 'itemlost' ], [ 'wthdrawn' ], [ 'itemcallnumber' ],
+        [ 'itemlost' ], [ 'withdrawn' ], [ 'itemcallnumber' ],
         [ 'issues' ], [ 'renewals' ], [ 'reserves' ],
         [ 'restricted' ], [ 'itemnotes' ], [ 'nonpublicnote' ],
         [ 'holdingbranch' ], [ 'paidfor' ], [ 'timestamp' ],
@@ -512,6 +515,25 @@ warning_like {( undef, $results_hashref, $facets_loop ) =
     $results_hashref->{'biblioserver'}->{"RECORDS"});
 is($newresults[0]->{'alternateholdings_count'}, 1, 'Alternate holdings filled in correctly');
 
+
+## Regression test for Bug 10741
+
+# make one of the test items appear to be in transit
+my $circ_module = new Test::MockModule('C4::Circulation');
+$circ_module->mock('GetTransfers', sub {
+    my $itemnumber = shift;
+    if ($itemnumber == 11) {
+        return ('2013-07-19', 'MPL', 'CPL');
+    } else {
+        return;
+    }
+});
+
+($error, $results_hashref, $facets_loop) = getRecords("TEST12121212","TEST12121212",[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
+@newresults = searchResults('intranet', $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
+    $results_hashref->{'biblioserver'}->{"RECORDS"});
+ok(!exists($newresults[0]->{norequests}), 'presence of a transit does not block hold request action (bug 10741)');
+
 END {
     if ($child) {
         kill 9, $child;