Lines 17-22
use C4::Members;
Link Here
|
17 |
use Koha::Database; |
17 |
use Koha::Database; |
18 |
use Koha::DateUtils; |
18 |
use Koha::DateUtils; |
19 |
use Koha::Items; |
19 |
use Koha::Items; |
|
|
20 |
use Koha::Holds; |
20 |
|
21 |
|
21 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 561-581
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Link Here
|
561 |
C4::HoldsQueue::CreateQueue(); |
562 |
C4::HoldsQueue::CreateQueue(); |
562 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
563 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
563 |
is( @$holds_queue, 1, "Hold where pickup branch matches home branch targeted" ); |
564 |
is( @$holds_queue, 1, "Hold where pickup branch matches home branch targeted" ); |
564 |
CancelReserve( { reserve_id => $reserve_id } ); |
565 |
Koha::Holds->find( $reserve_id )->cancel; |
565 |
|
566 |
|
566 |
# Holding branch matches pickup branch |
567 |
# Holding branch matches pickup branch |
567 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
568 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
568 |
C4::HoldsQueue::CreateQueue(); |
569 |
C4::HoldsQueue::CreateQueue(); |
569 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
570 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
570 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup eq home not targeted" ); |
571 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup eq home not targeted" ); |
571 |
CancelReserve( { reserve_id => $reserve_id } ); |
572 |
Koha::Holds->find( $reserve_id )->cancel; |
572 |
|
573 |
|
573 |
# Neither branch matches pickup branch |
574 |
# Neither branch matches pickup branch |
574 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
575 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
575 |
C4::HoldsQueue::CreateQueue(); |
576 |
C4::HoldsQueue::CreateQueue(); |
576 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
577 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
577 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" ); |
578 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" ); |
578 |
CancelReserve( { reserve_id => $reserve_id } ); |
579 |
Koha::Holds->find( $reserve_id )->cancel; |
579 |
|
580 |
|
580 |
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch |
581 |
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch |
581 |
$dbh->do("DELETE FROM default_circ_rules"); |
582 |
$dbh->do("DELETE FROM default_circ_rules"); |
Lines 586-606
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Link Here
|
586 |
C4::HoldsQueue::CreateQueue(); |
587 |
C4::HoldsQueue::CreateQueue(); |
587 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
588 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
588 |
is( @$holds_queue, 0, "Hold where pickup eq home, pickup ne holding not targeted" ); |
589 |
is( @$holds_queue, 0, "Hold where pickup eq home, pickup ne holding not targeted" ); |
589 |
CancelReserve( { reserve_id => $reserve_id } ); |
590 |
Koha::Holds->find( $reserve_id )->cancel; |
590 |
|
591 |
|
591 |
# Holding branch matches pickup branch |
592 |
# Holding branch matches pickup branch |
592 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
593 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
593 |
C4::HoldsQueue::CreateQueue(); |
594 |
C4::HoldsQueue::CreateQueue(); |
594 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
595 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
595 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" ); |
596 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" ); |
596 |
CancelReserve( { reserve_id => $reserve_id } ); |
597 |
Koha::Holds->find( $reserve_id )->cancel; |
597 |
|
598 |
|
598 |
# Neither branch matches pickup branch |
599 |
# Neither branch matches pickup branch |
599 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
600 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
600 |
C4::HoldsQueue::CreateQueue(); |
601 |
C4::HoldsQueue::CreateQueue(); |
601 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
602 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
602 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" ); |
603 |
is( @$holds_queue, 0, "Hold where pickup ne home, pickup ne holding not targeted" ); |
603 |
CancelReserve( { reserve_id => $reserve_id } ); |
604 |
Koha::Holds->find( $reserve_id )->cancel; |
604 |
|
605 |
|
605 |
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch |
606 |
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch |
606 |
$dbh->do("DELETE FROM default_circ_rules"); |
607 |
$dbh->do("DELETE FROM default_circ_rules"); |
Lines 611-631
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 );
Link Here
|
611 |
C4::HoldsQueue::CreateQueue(); |
612 |
C4::HoldsQueue::CreateQueue(); |
612 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
613 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
613 |
is( @$holds_queue, 1, "Hold where pickup eq home, pickup ne holding targeted" ); |
614 |
is( @$holds_queue, 1, "Hold where pickup eq home, pickup ne holding targeted" ); |
614 |
CancelReserve( { reserve_id => $reserve_id } ); |
615 |
Koha::Holds->find( $reserve_id )->cancel; |
615 |
|
616 |
|
616 |
# Holding branch matches pickup branch |
617 |
# Holding branch matches pickup branch |
617 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
618 |
$reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); |
618 |
C4::HoldsQueue::CreateQueue(); |
619 |
C4::HoldsQueue::CreateQueue(); |
619 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
620 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
620 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" ); |
621 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup eq holding targeted" ); |
621 |
CancelReserve( { reserve_id => $reserve_id } ); |
622 |
Koha::Holds->find( $reserve_id )->cancel; |
622 |
|
623 |
|
623 |
# Neither branch matches pickup branch |
624 |
# Neither branch matches pickup branch |
624 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
625 |
$reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); |
625 |
C4::HoldsQueue::CreateQueue(); |
626 |
C4::HoldsQueue::CreateQueue(); |
626 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
627 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
627 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup ne holding targeted" ); |
628 |
is( @$holds_queue, 1, "Hold where pickup ne home, pickup ne holding targeted" ); |
628 |
CancelReserve( { reserve_id => $reserve_id } ); |
629 |
Koha::Holds->find( $reserve_id )->cancel; |
629 |
|
630 |
|
630 |
# End testing hold_fulfillment_policy |
631 |
# End testing hold_fulfillment_policy |
631 |
|
632 |
|
Lines 673-693
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, und
Link Here
|
673 |
C4::HoldsQueue::CreateQueue(); |
674 |
C4::HoldsQueue::CreateQueue(); |
674 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
675 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
675 |
is( @$holds_queue, 0, "Item with incorrect itemtype not targeted" ); |
676 |
is( @$holds_queue, 0, "Item with incorrect itemtype not targeted" ); |
676 |
CancelReserve( { reserve_id => $reserve_id } ); |
677 |
Koha::Holds->find( $reserve_id )->cancel; |
677 |
|
678 |
|
678 |
# Holding branch matches pickup branch |
679 |
# Holding branch matches pickup branch |
679 |
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype ); |
680 |
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, $right_itemtype ); |
680 |
C4::HoldsQueue::CreateQueue(); |
681 |
C4::HoldsQueue::CreateQueue(); |
681 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
682 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
682 |
is( @$holds_queue, 1, "Item with matching itemtype is targeted" ); |
683 |
is( @$holds_queue, 1, "Item with matching itemtype is targeted" ); |
683 |
CancelReserve( { reserve_id => $reserve_id } ); |
684 |
Koha::Holds->find( $reserve_id )->cancel; |
684 |
|
685 |
|
685 |
# Neither branch matches pickup branch |
686 |
# Neither branch matches pickup branch |
686 |
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); |
687 |
$reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); |
687 |
C4::HoldsQueue::CreateQueue(); |
688 |
C4::HoldsQueue::CreateQueue(); |
688 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
689 |
$holds_queue = $dbh->selectall_arrayref( "SELECT * FROM tmp_holdsqueue", { Slice => {} } ); |
689 |
is( @$holds_queue, 1, "Item targeted when hold itemtype is not set" ); |
690 |
is( @$holds_queue, 1, "Item targeted when hold itemtype is not set" ); |
690 |
CancelReserve( { reserve_id => $reserve_id } ); |
691 |
Koha::Holds->find( $reserve_id )->cancel; |
691 |
|
692 |
|
692 |
# End testing hold itemtype limit |
693 |
# End testing hold itemtype limit |
693 |
|
694 |
|