Lines 794-826
Koha::Holds->find( $reserve_id )->cancel;
Link Here
|
794 |
# End testing hold itemtype limit |
794 |
# End testing hold itemtype limit |
795 |
|
795 |
|
796 |
|
796 |
|
797 |
# Test Local Holds Priority - Bug 18001 |
797 |
subtest "Test Local Holds Priority" => sub { |
798 |
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1); |
798 |
plan tests=>2; |
799 |
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
799 |
|
800 |
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
800 |
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1); |
801 |
|
801 |
t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); |
802 |
$dbh->do("DELETE FROM tmp_holdsqueue"); |
802 |
t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); |
803 |
$dbh->do("DELETE FROM hold_fill_targets"); |
803 |
my $branch = $builder->build_object({ class => 'Koha::Libraries' }); |
804 |
$dbh->do("DELETE FROM reserves"); |
804 |
my $branch2 = $builder->build_object({ class => 'Koha::Libraries' }); |
805 |
|
805 |
my $local_patron = $builder->build_object({ class=>"Koha::Patrons", value=>{ |
806 |
$item = Koha::Items->find( { biblionumber => $biblionumber } ); |
806 |
branchcode => $branch->branchcode |
807 |
$item->holdingbranch( $item->homebranch ); |
807 |
} |
808 |
$item->store(); |
808 |
}); |
809 |
|
809 |
my $other_patron = $builder->build_object({ class=>"Koha::Patrons", value=>{ |
810 |
my $item2 = Koha::Item->new( $item->unblessed ); |
810 |
branchcode => $branch2->branchcode |
811 |
$item2->itemnumber( undef ); |
811 |
} |
812 |
$item2->store(); |
812 |
}); |
813 |
|
813 |
my $biblio = $builder->build_sample_biblio(); |
814 |
my $item3 = Koha::Item->new( $item->unblessed ); |
814 |
my $item = $builder->build_sample_item({ |
815 |
$item3->itemnumber( undef ); |
815 |
biblionumber => $biblio->biblionumber, |
816 |
$item3->store(); |
816 |
homebranch => $branch->branchcode, |
|
|
817 |
holdingbranch => $branch->branchcode, |
818 |
}); |
819 |
|
820 |
my $item2 = $builder->build_sample_item({ |
821 |
biblionumber => $biblio->biblionumber, |
822 |
homebranch => $branch->branchcode, |
823 |
holdingbranch => $branch->branchcode, |
824 |
}); |
825 |
|
826 |
my $item3 = $builder->build_sample_item({ |
827 |
biblionumber => $biblio->biblionumber, |
828 |
homebranch => $branch->branchcode, |
829 |
holdingbranch => $branch->branchcode, |
830 |
}); |
831 |
|
832 |
my $reserve_id = AddReserve( $branch2->branchcode, $other_patron->borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); |
833 |
my $reserve_id2 = AddReserve( $item->homebranch, $local_patron->borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); |
817 |
|
834 |
|
818 |
$reserve_id = AddReserve( $item->homebranch, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); |
835 |
C4::HoldsQueue::CreateQueue(); |
819 |
|
836 |
|
820 |
C4::HoldsQueue::CreateQueue(); |
837 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
|
|
838 |
is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" ); |
839 |
is( $queue_rs->next->borrowernumber,$local_patron->borrowernumber,"We should pick the local hold over the next available"); |
821 |
|
840 |
|
822 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
841 |
}; |
823 |
is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" ); |
|
|
824 |
|
842 |
|
825 |
subtest 'Trivial test for UpdateTransportCostMatrix' => sub { |
843 |
subtest 'Trivial test for UpdateTransportCostMatrix' => sub { |
826 |
plan tests => 1; |
844 |
plan tests => 1; |
827 |
- |
|
|