Lines 8-14
Link Here
|
8 |
|
8 |
|
9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
10 |
|
10 |
|
11 |
use Test::More tests => 61; |
11 |
use Test::More tests => 62; |
12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
13 |
|
13 |
|
14 |
use C4::Calendar qw( new insert_single_holiday ); |
14 |
use C4::Calendar qw( new insert_single_holiday ); |
Lines 2090-2093
subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub {
Link Here
|
2090 |
is( scalar @$items, 2, "Two items without active transfers correctly retrieved"); |
2090 |
is( scalar @$items, 2, "Two items without active transfers correctly retrieved"); |
2091 |
is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); |
2091 |
is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); |
2092 |
|
2092 |
|
|
|
2093 |
$schema->storage->txn_rollback; |
2094 |
}; |
2095 |
|
2096 |
subtest "MapItemsToHoldRequests" => sub { |
2097 |
|
2098 |
plan tests => 1; |
2099 |
|
2100 |
$schema->storage->txn_begin; |
2101 |
|
2102 |
my $branch_closer = $builder->build_object( { class => 'Koha::Libraries' } ); |
2103 |
my $branch_farther = $builder->build_object( { class => 'Koha::Libraries' } ); |
2104 |
my $branch_pickup = $builder->build_object( { class => 'Koha::Libraries' } ); |
2105 |
|
2106 |
my $biblio = $builder->build_sample_biblio(); |
2107 |
my $item_farther = $builder->build_sample_item( |
2108 |
{ |
2109 |
biblionumber => $biblio->biblionumber, |
2110 |
library => $branch_farther->branchcode, |
2111 |
} |
2112 |
); |
2113 |
my $item_closer = $builder->build_sample_item( |
2114 |
{ |
2115 |
biblionumber => $biblio->biblionumber, |
2116 |
library => $branch_closer->branchcode, |
2117 |
} |
2118 |
); |
2119 |
|
2120 |
my $borrower = $builder->build({ |
2121 |
source => 'Borrower', |
2122 |
value => { |
2123 |
branchcode => $branch_pickup->branchcode, |
2124 |
} |
2125 |
}); |
2126 |
|
2127 |
my $res = AddReserve( |
2128 |
{ |
2129 |
branchcode => $branch_pickup->branchcode, |
2130 |
borrowernumber => $borrower->{borrowernumber}, |
2131 |
biblionumber => $item_farther->biblionumber, |
2132 |
priority => 1, |
2133 |
} |
2134 |
); |
2135 |
my $hold = Koha::Holds->find( $res ); |
2136 |
|
2137 |
my $transport_cost_matrix = {}; |
2138 |
$transport_cost_matrix->{$branch_pickup->id}->{$branch_closer->id}->{cost} = 5; |
2139 |
$transport_cost_matrix->{$branch_pickup->id}->{$branch_farther->id}->{cost} = 10; |
2140 |
my $map = C4::HoldsQueue::MapItemsToHoldRequests([$hold->unblessed], [$item_closer->unblessed, $item_farther->unblessed], undef, $transport_cost_matrix); |
2141 |
|
2142 |
my $priority_branch = 'homebranch'; |
2143 |
my $pickup_branch = $hold->branchcode; |
2144 |
my $items_by_branch = { $branch_farther->branchcode => [ $item_farther->unblessed ] }; |
2145 |
my $items_by_itemnumber = { $item_farther->id => [ $item_farther->unblessed ] }; |
2146 |
my $itemnumber = C4::HoldsQueue::get_least_cost_item( $priority_branch, $holdingbranch, $items_by_branch, $items_by_itemnumber, $libraries, $hold->unblessed ); |
2147 |
|
2148 |
is( $itemnumber, $item_farther->id, "Got the least cost item" ); |
2149 |
|
2150 |
$schema->storage->txn_rollback; |
2093 |
}; |
2151 |
}; |
2094 |
- |
|
|