Lines 300-306
subtest 'LookupPatron test' => sub {
Link Here
|
300 |
|
300 |
|
301 |
subtest 'Holds test' => sub { |
301 |
subtest 'Holds test' => sub { |
302 |
|
302 |
|
303 |
plan tests => 5; |
303 |
plan tests => 7; |
304 |
|
304 |
|
305 |
$schema->storage->txn_begin; |
305 |
$schema->storage->txn_begin; |
306 |
|
306 |
|
Lines 371-389
subtest 'Holds test' => sub {
Link Here
|
371 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
371 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
372 |
is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); |
372 |
is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); |
373 |
|
373 |
|
374 |
# Adding a holdable item to biblio 3. |
374 |
my $origin_branch = $builder->build( |
375 |
my $item3 = $builder->build_sample_item( |
|
|
376 |
{ |
375 |
{ |
377 |
damaged => 0, |
376 |
source => 'Branch', |
|
|
377 |
value => { |
378 |
pickup_location => 1, |
379 |
} |
378 |
} |
380 |
} |
379 |
); |
381 |
); |
380 |
|
382 |
|
|
|
383 |
# Adding a holdable item. |
384 |
my $item3 = $builder->build_sample_item( |
385 |
{ |
386 |
barcode => '123456789', |
387 |
library => $origin_branch->{branchcode} |
388 |
}); |
389 |
|
381 |
my $item4 = $builder->build_sample_item( |
390 |
my $item4 = $builder->build_sample_item( |
382 |
{ |
391 |
{ |
383 |
biblionumber => $item3->biblionumber, |
392 |
biblionumber => $item3->biblionumber, |
384 |
damaged => 1, |
393 |
damaged => 1, |
385 |
} |
394 |
library => $origin_branch->{branchcode} |
386 |
); |
395 |
}); |
387 |
|
396 |
|
388 |
Koha::CirculationRules->set_rule( |
397 |
Koha::CirculationRules->set_rule( |
389 |
{ |
398 |
{ |
Lines 397-408
subtest 'Holds test' => sub {
Link Here
|
397 |
|
406 |
|
398 |
$query = CGI->new; |
407 |
$query = CGI->new; |
399 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
408 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
400 |
$query->param( 'bib_id', $item3->biblionumber); |
409 |
$query->param( 'bib_id', $item4->biblionumber); |
401 |
$query->param( 'item_id', $item4->itemnumber); |
410 |
$query->param( 'item_id', $item4->itemnumber); |
402 |
|
411 |
|
403 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
412 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
404 |
is( $reply->{code}, 'damaged', "Item is damaged" ); |
413 |
is( $reply->{code}, 'damaged', "Item is damaged" ); |
405 |
|
414 |
|
|
|
415 |
my $module = new Test::MockModule('C4::Context'); |
416 |
$module->mock('userenv', sub { { patron => $patron } }); |
417 |
my $issue = C4::Circulation::AddIssue($patron, $item3->barcode); |
418 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' ); |
419 |
|
420 |
$query = new CGI; |
421 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
422 |
$query->param( 'bib_id', $item3->biblionumber); |
423 |
$query->param( 'item_id', $item3->itemnumber); |
424 |
$query->param( 'pickup_location', $origin_branch->{branchcode}); |
425 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
426 |
|
427 |
is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" ); |
428 |
is( $reply->{pickup_location}, undef, "No reserve placed"); |
429 |
|
406 |
$schema->storage->txn_rollback; |
430 |
$schema->storage->txn_rollback; |
407 |
}; |
431 |
}; |
408 |
|
432 |
|
Lines 642-648
subtest 'GetPatronInfo paginated loans' => sub {
Link Here
|
642 |
}); |
666 |
}); |
643 |
my $module = Test::MockModule->new('C4::Context'); |
667 |
my $module = Test::MockModule->new('C4::Context'); |
644 |
$module->mock('userenv', sub { { branch => $library->branchcode } }); |
668 |
$module->mock('userenv', sub { { branch => $library->branchcode } }); |
645 |
my $date_due = DateTime->now->add(weeks => 2); |
669 |
my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2); |
646 |
my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due); |
670 |
my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due); |
647 |
my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due ); |
671 |
my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due ); |
648 |
my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due); |
672 |
my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due); |