Lines 287-289
subtest 'LookupPatron test' => sub {
Link Here
|
287 |
# Cleanup |
287 |
# Cleanup |
288 |
$schema->storage->txn_rollback; |
288 |
$schema->storage->txn_rollback; |
289 |
}; |
289 |
}; |
290 |
- |
290 |
|
|
|
291 |
|
292 |
subtest 'Holds test' => sub { |
293 |
|
294 |
plan tests => 3; |
295 |
|
296 |
$schema->storage->txn_begin; |
297 |
|
298 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); |
299 |
|
300 |
my $patron = $builder->build({ |
301 |
source => 'Borrower', |
302 |
}); |
303 |
|
304 |
my $biblio = $builder->build({ |
305 |
source => 'Biblio', |
306 |
}); |
307 |
|
308 |
my $biblioitems = $builder->build({ |
309 |
source => 'Biblioitem', |
310 |
value => { |
311 |
biblionumber => $biblio->{biblionumber}, |
312 |
} |
313 |
}); |
314 |
|
315 |
my $item = $builder->build({ |
316 |
source => 'Item', |
317 |
value => { |
318 |
biblionumber => $biblio->{biblionumber}, |
319 |
damaged => 1 |
320 |
} |
321 |
}); |
322 |
|
323 |
my $query = new CGI; |
324 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
325 |
$query->param( 'bib_id', $biblio->{biblionumber}); |
326 |
|
327 |
my $reply = C4::ILSDI::Services::HoldTitle( $query ); |
328 |
is( $reply->{code}, 'damaged', "Item damaged" ); |
329 |
|
330 |
my $item_o = Koha::Items->find($item->{itemnumber}); |
331 |
$item_o->damaged(0)->store; |
332 |
|
333 |
my $hold = $builder->build({ |
334 |
source => 'Reserve', |
335 |
value => { |
336 |
borrowernumber => $patron->{borrowernumber}, |
337 |
biblionumber => $biblio->{biblionumber}, |
338 |
itemnumber => $item->{itemnumber} |
339 |
} |
340 |
}); |
341 |
|
342 |
$reply = C4::ILSDI::Services::HoldTitle( $query ); |
343 |
is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" ); |
344 |
|
345 |
my $biblio2 = $builder->build({ |
346 |
source => 'Biblio', |
347 |
}); |
348 |
|
349 |
my $biblioitems2 = $builder->build({ |
350 |
source => 'Biblioitem', |
351 |
value => { |
352 |
biblionumber => $biblio2->{biblionumber}, |
353 |
} |
354 |
}); |
355 |
|
356 |
my $item2 = $builder->build({ |
357 |
source => 'Item', |
358 |
value => { |
359 |
biblionumber => $biblio2->{biblionumber}, |
360 |
damaged => 0 |
361 |
} |
362 |
}); |
363 |
|
364 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
365 |
my $issuingrule = $builder->build({ |
366 |
source => 'Issuingrule', |
367 |
value => { |
368 |
categorycode => $patron->{categorycode}, |
369 |
itemtype => $item2->{itype}, |
370 |
branchcode => $patron->{branchcode}, |
371 |
reservesallowed => 0, |
372 |
} |
373 |
}); |
374 |
|
375 |
$query = new CGI; |
376 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
377 |
$query->param( 'bib_id', $biblio2->{biblionumber}); |
378 |
$query->param( 'item_id', $item2->{itemnumber}); |
379 |
|
380 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
381 |
is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); |
382 |
|
383 |
$schema->storage->txn_rollback; |
384 |
}; |