Lines 262-264
subtest 'LookupPatron test' => sub {
Link Here
|
262 |
# Cleanup |
262 |
# Cleanup |
263 |
$schema->storage->txn_rollback; |
263 |
$schema->storage->txn_rollback; |
264 |
}; |
264 |
}; |
265 |
- |
265 |
|
|
|
266 |
|
267 |
subtest 'Holds test' => sub { |
268 |
|
269 |
plan tests => 3; |
270 |
|
271 |
$schema->storage->txn_begin; |
272 |
|
273 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); |
274 |
|
275 |
my $patron = $builder->build({ |
276 |
source => 'Borrower', |
277 |
}); |
278 |
|
279 |
my $biblio = $builder->build({ |
280 |
source => 'Biblio', |
281 |
}); |
282 |
|
283 |
my $biblioitems = $builder->build({ |
284 |
source => 'Biblioitem', |
285 |
value => { |
286 |
biblionumber => $biblio->{biblionumber}, |
287 |
} |
288 |
}); |
289 |
|
290 |
my $item = $builder->build({ |
291 |
source => 'Item', |
292 |
value => { |
293 |
biblionumber => $biblio->{biblionumber}, |
294 |
damaged => 1 |
295 |
} |
296 |
}); |
297 |
|
298 |
my $query = new CGI; |
299 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
300 |
$query->param( 'bib_id', $biblio->{biblionumber}); |
301 |
|
302 |
my $reply = C4::ILSDI::Services::HoldTitle( $query ); |
303 |
is( $reply->{code}, 'damaged', "Item damaged" ); |
304 |
|
305 |
my $item_o = Koha::Items->find($item->{itemnumber}); |
306 |
$item_o->damaged(0)->store; |
307 |
|
308 |
my $hold = $builder->build({ |
309 |
source => 'Reserve', |
310 |
value => { |
311 |
borrowernumber => $patron->{borrowernumber}, |
312 |
biblionumber => $biblio->{biblionumber}, |
313 |
itemnumber => $item->{itemnumber} |
314 |
} |
315 |
}); |
316 |
|
317 |
$reply = C4::ILSDI::Services::HoldTitle( $query ); |
318 |
is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" ); |
319 |
|
320 |
my $biblio2 = $builder->build({ |
321 |
source => 'Biblio', |
322 |
}); |
323 |
|
324 |
my $biblioitems2 = $builder->build({ |
325 |
source => 'Biblioitem', |
326 |
value => { |
327 |
biblionumber => $biblio2->{biblionumber}, |
328 |
} |
329 |
}); |
330 |
|
331 |
my $item2 = $builder->build({ |
332 |
source => 'Item', |
333 |
value => { |
334 |
biblionumber => $biblio2->{biblionumber}, |
335 |
damaged => 0 |
336 |
} |
337 |
}); |
338 |
|
339 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
340 |
my $issuingrule = $builder->build({ |
341 |
source => 'Issuingrule', |
342 |
value => { |
343 |
categorycode => $patron->{categorycode}, |
344 |
itemtype => $item2->{itype}, |
345 |
branchcode => $patron->{branchcode}, |
346 |
reservesallowed => 0, |
347 |
} |
348 |
}); |
349 |
|
350 |
$query = new CGI; |
351 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
352 |
$query->param( 'bib_id', $biblio2->{biblionumber}); |
353 |
$query->param( 'item_id', $item2->{itemnumber}); |
354 |
|
355 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
356 |
is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); |
357 |
|
358 |
$schema->storage->txn_rollback; |
359 |
}; |