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 23-28
use Koha::CirculationRules;
Link Here
|
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
|
26 |
use Test::MockModule; |
27 |
use Test::Warn; |
26 |
|
28 |
|
27 |
BEGIN { |
29 |
BEGIN { |
28 |
use FindBin; |
30 |
use FindBin; |
Lines 38-43
$dbh->do("DELETE FROM circulation_rules");
Link Here
|
38 |
|
40 |
|
39 |
my $builder = t::lib::TestBuilder->new; |
41 |
my $builder = t::lib::TestBuilder->new; |
40 |
|
42 |
|
|
|
43 |
subtest "MapItemsToHoldRequests tests" => sub { |
44 |
plan tests => 1; |
45 |
|
46 |
$schema->storage->txn_begin; |
47 |
|
48 |
subtest "TransportCostMatrix tests" => sub { |
49 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); |
50 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); |
51 |
my $HoldsQueue = Test::MockModule->new('C4::HoldsQueue'); |
52 |
$HoldsQueue->mock( |
53 |
'least_cost_branch', |
54 |
sub { |
55 |
warn "Checking transport cost matrix"; |
56 |
return; |
57 |
} |
58 |
); |
59 |
|
60 |
my $branch_a = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
61 |
my $branch_b = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
62 |
my $item_1 = $builder->build_sample_item( |
63 |
{ homebranch => $branch_a->branchcode, holdingbranch => $branch_b->branchcode } ); |
64 |
my $patron = $builder->build_object( |
65 |
{ |
66 |
class => "Koha::Patrons", |
67 |
value => { |
68 |
branchcode => $branch_b->branchcode, |
69 |
} |
70 |
} |
71 |
); |
72 |
my $hold = $builder->build_object( |
73 |
{ |
74 |
class => 'Koha::Holds', |
75 |
value => { |
76 |
itemnumber => undef, |
77 |
biblionumber => $item_1->biblionumber, |
78 |
branchcode => $branch_b->branchcode, |
79 |
item_level_hold => 0, |
80 |
item_group_id => undef, |
81 |
itemtype => undef, |
82 |
borrowernumber => $patron->id, |
83 |
} |
84 |
} |
85 |
); |
86 |
|
87 |
my $tcm = { |
88 |
$branch_b->branchcode => { |
89 |
$branch_a->branchcode => { cost => 10 }, |
90 |
} |
91 |
}; |
92 |
|
93 |
my $hq_item = $item_1->unblessed; |
94 |
$hq_item->{holdallowed} = 'from_any_library'; |
95 |
$hq_item->{hold_fullfillment_policy} = 'any'; |
96 |
my $hq_hold = $hold->unblessed; |
97 |
$hq_hold->{borrowerbranch} = $branch_b->branchcode; |
98 |
warning_is { |
99 |
C4::HoldsQueue::MapItemsToHoldRequests( [$hq_hold], [$hq_item], [ $branch_a->branchcode ], $tcm ); |
100 |
} |
101 |
"Checking transport cost matrix", |
102 |
"Transport cost matrix is checked when HoldsQueuePrioritizeBranch does not match"; |
103 |
|
104 |
}; |
105 |
|
106 |
$schema->storage->txn_rollback; |
107 |
}; |
108 |
|
41 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '0' ); |
109 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '0' ); |
42 |
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); |
110 |
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); |
43 |
|
111 |
|
Lines 2091-2093
subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub {
Link Here
|
2091 |
is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); |
2159 |
is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); |
2092 |
|
2160 |
|
2093 |
}; |
2161 |
}; |
2094 |
- |
2162 |
|
|
|
2163 |
|
2164 |
|