View | Details | Raw Unified | Return to bug 27069
Collapse All | Expand All

(-)a/t/db_dependent/Circulation/Branch.t (-9 / +9 lines)
Lines 174-180 Koha::CirculationRules->set_rules( Link Here
174
        branchcode   => $samplebranch2->{branchcode},
174
        branchcode   => $samplebranch2->{branchcode},
175
        itemtype     => undef,
175
        itemtype     => undef,
176
        rules        => {
176
        rules        => {
177
            holdallowed       => 1,
177
            holdallowed       => 'from_home_library',
178
            returnbranch      => 'holdingbranch',
178
            returnbranch      => 'holdingbranch',
179
        }
179
        }
180
    }
180
    }
Lines 195-201 Koha::CirculationRules->set_rules( Link Here
195
        branchcode   => undef,
195
        branchcode   => undef,
196
        itemtype     => undef,
196
        itemtype     => undef,
197
        rules        => {
197
        rules        => {
198
            holdallowed       => 3,
198
            holdallowed       => 'from_local_hold_group',
199
            returnbranch      => 'homebranch',
199
            returnbranch      => 'homebranch',
200
        }
200
        }
201
    }
201
    }
Lines 206-212 Koha::CirculationRules->set_rules( Link Here
206
        branchcode   => $samplebranch1->{branchcode},
206
        branchcode   => $samplebranch1->{branchcode},
207
        itemtype     => $sampleitemtype1->{itemtype},
207
        itemtype     => $sampleitemtype1->{itemtype},
208
        rules        => {
208
        rules        => {
209
            holdallowed       => 5,
209
            holdallowed       => 'invalid_value',
210
            returnbranch      => 'homebranch',
210
            returnbranch      => 'homebranch',
211
        }
211
        }
212
    }
212
    }
Lines 216-222 Koha::CirculationRules->set_rules( Link Here
216
        branchcode   => $samplebranch2->{branchcode},
216
        branchcode   => $samplebranch2->{branchcode},
217
        itemtype     => $sampleitemtype1->{itemtype},
217
        itemtype     => $sampleitemtype1->{itemtype},
218
        rules        => {
218
        rules        => {
219
            holdallowed       => 5,
219
            holdallowed       => 'invalid_value',
220
            returnbranch      => 'holdingbranch',
220
            returnbranch      => 'holdingbranch',
221
        }
221
        }
222
    }
222
    }
Lines 226-232 Koha::CirculationRules->set_rules( Link Here
226
        branchcode   => $samplebranch2->{branchcode},
226
        branchcode   => $samplebranch2->{branchcode},
227
        itemtype     => $sampleitemtype2->{itemtype},
227
        itemtype     => $sampleitemtype2->{itemtype},
228
        rules        => {
228
        rules        => {
229
            holdallowed       => 5,
229
            holdallowed       => 'invalid_value',
230
            returnbranch      => 'noreturn',
230
            returnbranch      => 'noreturn',
231
        }
231
        }
232
    }
232
    }
Lines 264-285 is_deeply( Link Here
264
        $samplebranch1->{branchcode},
264
        $samplebranch1->{branchcode},
265
        $sampleitemtype1->{itemtype},
265
        $sampleitemtype1->{itemtype},
266
    ),
266
    ),
267
    { returnbranch => 'homebranch', holdallowed => 5, @lazy_any },
267
    { returnbranch => 'homebranch', holdallowed => 'invalid_value', @lazy_any },
268
    "GetBranchitem returns holdallowed and return branch"
268
    "GetBranchitem returns holdallowed and return branch"
269
);
269
);
270
is_deeply(
270
is_deeply(
271
    GetBranchItemRule(),
271
    GetBranchItemRule(),
272
    { returnbranch => 'homebranch', holdallowed => 3, @lazy_any },
272
    { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any },
273
"Without parameters GetBranchItemRule returns the values in default_circ_rules"
273
"Without parameters GetBranchItemRule returns the values in default_circ_rules"
274
);
274
);
275
is_deeply(
275
is_deeply(
276
    GetBranchItemRule( $samplebranch2->{branchcode} ),
276
    GetBranchItemRule( $samplebranch2->{branchcode} ),
277
    { returnbranch => 'holdingbranch', holdallowed => 1, @lazy_any },
277
    { returnbranch => 'holdingbranch', holdallowed => 'from_home_library', @lazy_any },
278
"With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules"
278
"With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules"
279
);
279
);
280
is_deeply(
280
is_deeply(
281
    GetBranchItemRule( -1, -1 ),
281
    GetBranchItemRule( -1, -1 ),
282
    { returnbranch => 'homebranch', holdallowed => 3, @lazy_any },
282
    { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any },
283
    "With only one parametern GetBranchItemRule returns default values"
283
    "With only one parametern GetBranchItemRule returns default values"
284
);
284
);
285
285
(-)a/t/db_dependent/Holds.t (-16 / +16 lines)
Lines 420-426 Koha::CirculationRules->set_rules( Link Here
420
        branchcode => $branch_1,
420
        branchcode => $branch_1,
421
        itemtype   => 'CANNOT',
421
        itemtype   => 'CANNOT',
422
        rules => {
422
        rules => {
423
            holdallowed => 0,
423
            holdallowed => 'not_allowed',
424
            returnbranch => 'homebranch',
424
            returnbranch => 'homebranch',
425
        }
425
        }
426
    }
426
    }
Lines 430-436 Koha::CirculationRules->set_rules( Link Here
430
        branchcode => $branch_1,
430
        branchcode => $branch_1,
431
        itemtype   => 'CAN',
431
        itemtype   => 'CAN',
432
        rules => {
432
        rules => {
433
            holdallowed => 1,
433
            holdallowed => 'from_home_library',
434
            returnbranch => 'homebranch',
434
            returnbranch => 'homebranch',
435
        }
435
        }
436
    }
436
    }
Lines 877-883 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
877
            branchcode => undef,
877
            branchcode => undef,
878
            itemtype   => undef,
878
            itemtype   => undef,
879
            rules => {
879
            rules => {
880
                holdallowed => 3,
880
                holdallowed => 'from_local_hold_group',
881
                hold_fulfillment_policy => 'any',
881
                hold_fulfillment_policy => 'any',
882
                returnbranch => 'any'
882
                returnbranch => 'any'
883
            }
883
            }
Lines 904-910 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
904
            branchcode => $library2->branchcode,
904
            branchcode => $library2->branchcode,
905
            itemtype   => undef,
905
            itemtype   => undef,
906
            rules => {
906
            rules => {
907
                holdallowed => 2,
907
                holdallowed => 'from_any_library',
908
                hold_fulfillment_policy => 'any',
908
                hold_fulfillment_policy => 'any',
909
                returnbranch => 'any'
909
                returnbranch => 'any'
910
            }
910
            }
Lines 924-930 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
924
            branchcode => $library2->branchcode,
924
            branchcode => $library2->branchcode,
925
            itemtype   => undef,
925
            itemtype   => undef,
926
            rules => {
926
            rules => {
927
                holdallowed => 3,
927
                holdallowed => 'from_local_hold_group',
928
                hold_fulfillment_policy => 'any',
928
                hold_fulfillment_policy => 'any',
929
                returnbranch => 'any'
929
                returnbranch => 'any'
930
            }
930
            }
Lines 944-950 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
944
            branchcode => $library2->branchcode,
944
            branchcode => $library2->branchcode,
945
            itemtype   => $itemtype2->itemtype,
945
            itemtype   => $itemtype2->itemtype,
946
            rules => {
946
            rules => {
947
                holdallowed => 2,
947
                holdallowed => 'from_any_library',
948
                hold_fulfillment_policy => 'any',
948
                hold_fulfillment_policy => 'any',
949
                returnbranch => 'any'
949
                returnbranch => 'any'
950
            }
950
            }
Lines 964-970 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
964
            branchcode => $library2->branchcode,
964
            branchcode => $library2->branchcode,
965
            itemtype   => $itemtype2->itemtype,
965
            itemtype   => $itemtype2->itemtype,
966
            rules => {
966
            rules => {
967
                holdallowed => 3,
967
                holdallowed => 'from_local_hold_group',
968
                hold_fulfillment_policy => 'any',
968
                hold_fulfillment_policy => 'any',
969
                returnbranch => 'any'
969
                returnbranch => 'any'
970
            }
970
            }
Lines 984-990 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
984
            branchcode => $library2->branchcode,
984
            branchcode => $library2->branchcode,
985
            itemtype   => $itemtype2->itemtype,
985
            itemtype   => $itemtype2->itemtype,
986
            rules => {
986
            rules => {
987
                holdallowed => 2,
987
                holdallowed => 'from_any_library',
988
                hold_fulfillment_policy => 'any',
988
                hold_fulfillment_policy => 'any',
989
                returnbranch => 'any'
989
                returnbranch => 'any'
990
            }
990
            }
Lines 1004-1010 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
1004
            branchcode => $library2->branchcode,
1004
            branchcode => $library2->branchcode,
1005
            itemtype   => $itemtype2->itemtype,
1005
            itemtype   => $itemtype2->itemtype,
1006
            rules => {
1006
            rules => {
1007
                holdallowed => 3,
1007
                holdallowed => 'from_local_hold_group',
1008
                hold_fulfillment_policy => 'any',
1008
                hold_fulfillment_policy => 'any',
1009
                returnbranch => 'any'
1009
                returnbranch => 'any'
1010
            }
1010
            }
Lines 1091-1097 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1091
            branchcode => undef,
1091
            branchcode => undef,
1092
            itemtype   => undef,
1092
            itemtype   => undef,
1093
            rules => {
1093
            rules => {
1094
                holdallowed => 2,
1094
                holdallowed => 'from_any_library',
1095
                hold_fulfillment_policy => 'holdgroup',
1095
                hold_fulfillment_policy => 'holdgroup',
1096
                returnbranch => 'any'
1096
                returnbranch => 'any'
1097
            }
1097
            }
Lines 1118-1124 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1118
            branchcode => $library2->branchcode,
1118
            branchcode => $library2->branchcode,
1119
            itemtype   => undef,
1119
            itemtype   => undef,
1120
            rules => {
1120
            rules => {
1121
                holdallowed => 2,
1121
                holdallowed => 'from_any_library',
1122
                hold_fulfillment_policy => 'any',
1122
                hold_fulfillment_policy => 'any',
1123
                returnbranch => 'any'
1123
                returnbranch => 'any'
1124
            }
1124
            }
Lines 1138-1144 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1138
            branchcode => $library2->branchcode,
1138
            branchcode => $library2->branchcode,
1139
            itemtype   => undef,
1139
            itemtype   => undef,
1140
            rules => {
1140
            rules => {
1141
                holdallowed => 2,
1141
                holdallowed => 'from_any_library',
1142
                hold_fulfillment_policy => 'holdgroup',
1142
                hold_fulfillment_policy => 'holdgroup',
1143
                returnbranch => 'any'
1143
                returnbranch => 'any'
1144
            }
1144
            }
Lines 1158-1164 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1158
            branchcode => $library2->branchcode,
1158
            branchcode => $library2->branchcode,
1159
            itemtype   => $itemtype2->itemtype,
1159
            itemtype   => $itemtype2->itemtype,
1160
            rules => {
1160
            rules => {
1161
                holdallowed => 2,
1161
                holdallowed => 'from_any_library',
1162
                hold_fulfillment_policy => 'any',
1162
                hold_fulfillment_policy => 'any',
1163
                returnbranch => 'any'
1163
                returnbranch => 'any'
1164
            }
1164
            }
Lines 1178-1184 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1178
            branchcode => $library2->branchcode,
1178
            branchcode => $library2->branchcode,
1179
            itemtype   => $itemtype2->itemtype,
1179
            itemtype   => $itemtype2->itemtype,
1180
            rules => {
1180
            rules => {
1181
                holdallowed => 2,
1181
                holdallowed => 'from_any_library',
1182
                hold_fulfillment_policy => 'holdgroup',
1182
                hold_fulfillment_policy => 'holdgroup',
1183
                returnbranch => 'any'
1183
                returnbranch => 'any'
1184
            }
1184
            }
Lines 1198-1204 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1198
            branchcode => $library2->branchcode,
1198
            branchcode => $library2->branchcode,
1199
            itemtype   => $itemtype2->itemtype,
1199
            itemtype   => $itemtype2->itemtype,
1200
            rules => {
1200
            rules => {
1201
                holdallowed => 2,
1201
                holdallowed => 'from_any_library',
1202
                hold_fulfillment_policy => 'any',
1202
                hold_fulfillment_policy => 'any',
1203
                returnbranch => 'any'
1203
                returnbranch => 'any'
1204
            }
1204
            }
Lines 1218-1224 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1218
            branchcode => $library2->branchcode,
1218
            branchcode => $library2->branchcode,
1219
            itemtype   => $itemtype2->itemtype,
1219
            itemtype   => $itemtype2->itemtype,
1220
            rules => {
1220
            rules => {
1221
                holdallowed => 2,
1221
                holdallowed => 'from_any_library',
1222
                hold_fulfillment_policy => 'holdgroup',
1222
                hold_fulfillment_policy => 'holdgroup',
1223
                returnbranch => 'any'
1223
                returnbranch => 'any'
1224
            }
1224
            }
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-2 / +2 lines)
Lines 126-133 AddReturn( $item1->barcode ); Link Here
126
    subtest 'IsAvailableForItemLevelRequest behaviours depending on ReservesControlBranch + holdallowed' => sub {
126
    subtest 'IsAvailableForItemLevelRequest behaviours depending on ReservesControlBranch + holdallowed' => sub {
127
        plan tests => 2;
127
        plan tests => 2;
128
128
129
        my $hold_allowed_from_home_library  = 1;
129
        my $hold_allowed_from_home_library  = 'from_home_library';
130
        my $hold_allowed_from_any_libraries = 2;
130
        my $hold_allowed_from_any_libraries = 'from_any_library';
131
131
132
        subtest 'Item is available at a different library' => sub {
132
        subtest 'Item is available at a different library' => sub {
133
            plan tests => 13;
133
            plan tests => 13;
(-)a/t/db_dependent/Holds/HoldFulfillmentPolicy.t (-3 / +3 lines)
Lines 78-84 Koha::CirculationRules->set_rules( Link Here
78
        branchcode   => undef,
78
        branchcode   => undef,
79
        itemtype     => undef,
79
        itemtype     => undef,
80
        rules        => {
80
        rules        => {
81
            holdallowed             => 2,
81
            holdallowed             => 'from_any_library',
82
            hold_fulfillment_policy => 'homebranch',
82
            hold_fulfillment_policy => 'homebranch',
83
        }
83
        }
84
    }
84
    }
Lines 130-136 Koha::CirculationRules->set_rules( Link Here
130
        branchcode   => undef,
130
        branchcode   => undef,
131
        itemtype     => undef,
131
        itemtype     => undef,
132
        rules        => {
132
        rules        => {
133
            holdallowed             => 2,
133
            holdallowed             => 'from_any_library',
134
            hold_fulfillment_policy => 'holdingbranch',
134
            hold_fulfillment_policy => 'holdingbranch',
135
        }
135
        }
136
    }
136
    }
Lines 182-188 Koha::CirculationRules->set_rules( Link Here
182
        branchcode   => undef,
182
        branchcode   => undef,
183
        itemtype     => undef,
183
        itemtype     => undef,
184
        rules        => {
184
        rules        => {
185
            holdallowed             => 2,
185
            holdallowed             => 'from_any_library',
186
            hold_fulfillment_policy => 'any',
186
            hold_fulfillment_policy => 'any',
187
        }
187
        }
188
    }
188
    }
(-)a/t/db_dependent/HoldsQueue.t (-20 / +20 lines)
Lines 309-315 $dbh->do("DELETE FROM circulation_rules"); Link Here
309
Koha::CirculationRules->set_rule(
309
Koha::CirculationRules->set_rule(
310
    {
310
    {
311
        rule_name    => 'holdallowed',
311
        rule_name    => 'holdallowed',
312
        rule_value   => 1,
312
        rule_value   => 'from_home_library',
313
        branchcode   => undef,
313
        branchcode   => undef,
314
        itemtype     => undef,
314
        itemtype     => undef,
315
    }
315
    }
Lines 346-352 $dbh->do("DELETE FROM circulation_rules"); Link Here
346
Koha::CirculationRules->set_rule(
346
Koha::CirculationRules->set_rule(
347
    {
347
    {
348
        rule_name    => 'holdallowed',
348
        rule_name    => 'holdallowed',
349
        rule_value   => 2,
349
        rule_value   => 'from_any_library',
350
        branchcode   => undef,
350
        branchcode   => undef,
351
        itemtype     => undef,
351
        itemtype     => undef,
352
    }
352
    }
Lines 373-379 $dbh->do("DELETE FROM circulation_rules"); Link Here
373
Koha::CirculationRules->set_rule(
373
Koha::CirculationRules->set_rule(
374
    {
374
    {
375
        rule_name    => 'holdallowed',
375
        rule_name    => 'holdallowed',
376
        rule_value   => 2,
376
        rule_value   => 'from_any_library',
377
        branchcode   => undef,
377
        branchcode   => undef,
378
        itemtype     => undef,
378
        itemtype     => undef,
379
    }
379
    }
Lines 538-544 Koha::CirculationRules->set_rules( Link Here
538
        branchcode   => $library_A,
538
        branchcode   => $library_A,
539
        itemtype     => $itemtype,
539
        itemtype     => $itemtype,
540
        rules        => {
540
        rules        => {
541
            holdallowed  => 2,
541
            holdallowed  => 'from_any_library',
542
            returnbranch => 'homebranch',
542
            returnbranch => 'homebranch',
543
        }
543
        }
544
    }
544
    }
Lines 651-657 Koha::CirculationRules->set_rules( Link Here
651
        branchcode   => undef,
651
        branchcode   => undef,
652
        itemtype     => undef,
652
        itemtype     => undef,
653
        rules        => {
653
        rules        => {
654
            holdallowed             => 2,
654
            holdallowed             => 'from_any_library',
655
            hold_fulfillment_policy => 'homebranch',
655
            hold_fulfillment_policy => 'homebranch',
656
        }
656
        }
657
    }
657
    }
Lines 712-718 Koha::CirculationRules->set_rules( Link Here
712
        branchcode   => undef,
712
        branchcode   => undef,
713
        itemtype     => undef,
713
        itemtype     => undef,
714
        rules        => {
714
        rules        => {
715
            holdallowed             => 2,
715
            holdallowed             => 'from_any_library',
716
            hold_fulfillment_policy => 'holdingbranch',
716
            hold_fulfillment_policy => 'holdingbranch',
717
        }
717
        }
718
    }
718
    }
Lines 770-776 Koha::CirculationRules->set_rules( Link Here
770
        branchcode   => undef,
770
        branchcode   => undef,
771
        itemtype     => undef,
771
        itemtype     => undef,
772
        rules        => {
772
        rules        => {
773
            holdallowed             => 2,
773
            holdallowed             => 'from_any_library',
774
            hold_fulfillment_policy => 'any',
774
            hold_fulfillment_policy => 'any',
775
        }
775
        }
776
    }
776
    }
Lines 861-867 Koha::CirculationRules->set_rules( Link Here
861
        branchcode   => undef,
861
        branchcode   => undef,
862
        itemtype     => undef,
862
        itemtype     => undef,
863
        rules        => {
863
        rules        => {
864
            holdallowed             => 2,
864
            holdallowed             => 'from_any_library',
865
            hold_fulfillment_policy => 'any',
865
            hold_fulfillment_policy => 'any',
866
        }
866
        }
867
    }
867
    }
Lines 1572-1578 subtest "Test _checkHoldPolicy" => sub { Link Here
1572
    ok( $hold, "Found hold" );
1572
    ok( $hold, "Found hold" );
1573
1573
1574
    my $item = {
1574
    my $item = {
1575
        holdallowed              => 1,
1575
        holdallowed              => 'from_home_library',
1576
        homebranch               => $request->{borrowerbranch}, # library1
1576
        homebranch               => $request->{borrowerbranch}, # library1
1577
        hold_fulfillment_policy  => 'any'
1577
        hold_fulfillment_policy  => 'any'
1578
    };
1578
    };
Lines 1580-1610 subtest "Test _checkHoldPolicy" => sub { Link Here
1580
    # Base case should work
1580
    # Base case should work
1581
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true" );
1581
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true" );
1582
1582
1583
    # Test holdallowed = 0
1583
    # Test holdallowed = 'not_allowed'
1584
    $item->{holdallowed} = 0;
1584
    $item->{holdallowed} = 'not_allowed';
1585
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = 0" );
1585
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = not_allowed" );
1586
1586
1587
    # Test holdallowed = 1
1587
    # Test holdallowed = 'from_home_library'
1588
    $item->{holdallowed} = 1;
1588
    $item->{holdallowed} = 'from_home_library';
1589
    $item->{homebranch} = $library_nongroup->id;
1589
    $item->{homebranch} = $library_nongroup->id;
1590
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = 1 and branches do not match" );
1590
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = from_home_library and branches do not match" );
1591
1591
1592
    $item->{homebranch} = $request->{borrowerbranch};
1592
    $item->{homebranch} = $request->{borrowerbranch};
1593
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = 1 and branches do match" );
1593
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = from_home_library and branches do match" );
1594
1594
1595
    # Test holdallowed = 3
1595
    # Test holdallowed = 3
1596
    $item->{holdallowed} = 3;
1596
    $item->{holdallowed} = 'from_local_hold_group';
1597
    $item->{homebranch} = $library_nongroup->id;
1597
    $item->{homebranch} = $library_nongroup->id;
1598
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if branchode doesn't match, holdallowed = 3 and no group branches exist" );
1598
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if branchode doesn't match, holdallowed = from_local_hold_group and no group branches exist" );
1599
    $item->{homebranch} = $request->{borrowerbranch};
1599
    $item->{homebranch} = $request->{borrowerbranch};
1600
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if branchode matches, holdallowed = 3 and no group branches exist" );
1600
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if branchode matches, holdallowed = from_local_hold_group and no group branches exist" );
1601
1601
1602
    # Create library groups hierarchy
1602
    # Create library groups hierarchy
1603
    my $rootgroup = $builder->build_object( { class => 'Koha::Library::Groups', value => {ft_local_hold_group => 1} } );
1603
    my $rootgroup = $builder->build_object( { class => 'Koha::Library::Groups', value => {ft_local_hold_group => 1} } );
1604
    my $group1 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library1->branchcode}} );
1604
    my $group1 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library1->branchcode}} );
1605
    my $group2 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library2->branchcode}} );
1605
    my $group2 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library2->branchcode}} );
1606
1606
1607
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = 3 and no group branches exist" );
1607
    is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = from_local_hold_group and no group branches exist" );
1608
1608
1609
    $group1->delete;
1609
    $group1->delete;
1610
1610
(-)a/t/db_dependent/Koha/Biblio.t (-8 / +8 lines)
Lines 221-227 subtest 'pickup_locations' => sub { Link Here
221
            branchcode => $library1->branchcode,
221
            branchcode => $library1->branchcode,
222
            itemtype   => undef,
222
            itemtype   => undef,
223
            rules => {
223
            rules => {
224
                holdallowed => 1,
224
                holdallowed => 'from_home_library',
225
                hold_fulfillment_policy => 'any',
225
                hold_fulfillment_policy => 'any',
226
                returnbranch => 'any'
226
                returnbranch => 'any'
227
            }
227
            }
Lines 233-239 subtest 'pickup_locations' => sub { Link Here
233
            branchcode => $library2->branchcode,
233
            branchcode => $library2->branchcode,
234
            itemtype   => undef,
234
            itemtype   => undef,
235
            rules => {
235
            rules => {
236
                holdallowed => 3,
236
                holdallowed => 'from_local_hold_group',
237
                hold_fulfillment_policy => 'holdgroup',
237
                hold_fulfillment_policy => 'holdgroup',
238
                returnbranch => 'any'
238
                returnbranch => 'any'
239
            }
239
            }
Lines 245-251 subtest 'pickup_locations' => sub { Link Here
245
            branchcode => $library3->branchcode,
245
            branchcode => $library3->branchcode,
246
            itemtype   => undef,
246
            itemtype   => undef,
247
            rules => {
247
            rules => {
248
                holdallowed => 3,
248
                holdallowed => 'from_local_hold_group',
249
                hold_fulfillment_policy => 'patrongroup',
249
                hold_fulfillment_policy => 'patrongroup',
250
                returnbranch => 'any'
250
                returnbranch => 'any'
251
            }
251
            }
Lines 257-263 subtest 'pickup_locations' => sub { Link Here
257
            branchcode => $library4->branchcode,
257
            branchcode => $library4->branchcode,
258
            itemtype   => undef,
258
            itemtype   => undef,
259
            rules => {
259
            rules => {
260
                holdallowed => 2,
260
                holdallowed => 'from_any_library',
261
                hold_fulfillment_policy => 'holdingbranch',
261
                hold_fulfillment_policy => 'holdingbranch',
262
                returnbranch => 'any'
262
                returnbranch => 'any'
263
            }
263
            }
Lines 269-275 subtest 'pickup_locations' => sub { Link Here
269
            branchcode => $library5->branchcode,
269
            branchcode => $library5->branchcode,
270
            itemtype   => undef,
270
            itemtype   => undef,
271
            rules => {
271
            rules => {
272
                holdallowed => 2,
272
                holdallowed => 'from_any_library',
273
                hold_fulfillment_policy => 'homebranch',
273
                hold_fulfillment_policy => 'homebranch',
274
                returnbranch => 'any'
274
                returnbranch => 'any'
275
            }
275
            }
Lines 281-287 subtest 'pickup_locations' => sub { Link Here
281
            branchcode => $library6->branchcode,
281
            branchcode => $library6->branchcode,
282
            itemtype   => undef,
282
            itemtype   => undef,
283
            rules => {
283
            rules => {
284
                holdallowed => 1,
284
                holdallowed => 'from_home_library',
285
                hold_fulfillment_policy => 'holdgroup',
285
                hold_fulfillment_policy => 'holdgroup',
286
                returnbranch => 'any'
286
                returnbranch => 'any'
287
            }
287
            }
Lines 293-299 subtest 'pickup_locations' => sub { Link Here
293
            branchcode => $library7->branchcode,
293
            branchcode => $library7->branchcode,
294
            itemtype   => undef,
294
            itemtype   => undef,
295
            rules => {
295
            rules => {
296
                holdallowed => 3,
296
                holdallowed => 'from_local_hold_group',
297
                hold_fulfillment_policy => 'holdingbranch',
297
                hold_fulfillment_policy => 'holdingbranch',
298
                returnbranch => 'any'
298
                returnbranch => 'any'
299
            }
299
            }
Lines 306-312 subtest 'pickup_locations' => sub { Link Here
306
            branchcode => $library8->branchcode,
306
            branchcode => $library8->branchcode,
307
            itemtype   => undef,
307
            itemtype   => undef,
308
            rules => {
308
            rules => {
309
                holdallowed => 2,
309
                holdallowed => 'from_any_library',
310
                hold_fulfillment_policy => 'patrongroup',
310
                hold_fulfillment_policy => 'patrongroup',
311
                returnbranch => 'any'
311
                returnbranch => 'any'
312
            }
312
            }
(-)a/t/db_dependent/Koha/Holds.t (-1 / +1 lines)
Lines 490-496 subtest 'get_items_that_can_fill' => sub { Link Here
490
    Koha::CirculationRule->new(
490
    Koha::CirculationRule->new(
491
        {
491
        {
492
            rule_name  => 'holdallowed',
492
            rule_name  => 'holdallowed',
493
            rule_value => 0,
493
            rule_value => 'not_allowed',
494
            itemtype   => $item_5->itype
494
            itemtype   => $item_5->itype
495
        }
495
        }
496
    )->store;
496
    )->store;
(-)a/t/db_dependent/Koha/Item.t (-64 / +69 lines)
Lines 215-280 subtest 'pickup_locations' => sub { Link Here
215
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
215
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
216
216
217
    my $results = {
217
    my $results = {
218
        "1-1-1-any"           => 3,
218
        "1-1-from_home_library-any"               => 3,
219
        "1-1-1-holdgroup"     => 2,
219
        "1-1-from_home_library-holdgroup"         => 2,
220
        "1-1-1-patrongroup"   => 2,
220
        "1-1-from_home_library-patrongroup"       => 2,
221
        "1-1-1-homebranch"    => 1,
221
        "1-1-from_home_library-homebranch"        => 1,
222
        "1-1-1-holdingbranch" => 1,
222
        "1-1-from_home_library-holdingbranch"     => 1,
223
        "1-1-2-any"           => 3,
223
        "1-1-from_any_library-any"                => 3,
224
        "1-1-2-holdgroup"     => 2,
224
        "1-1-from_any_library-holdgroup"          => 2,
225
        "1-1-2-patrongroup"   => 2,
225
        "1-1-from_any_library-patrongroup"        => 2,
226
        "1-1-2-homebranch"    => 1,
226
        "1-1-from_any_library-homebranch"         => 1,
227
        "1-1-2-holdingbranch" => 1,
227
        "1-1-from_any_library-holdingbranch"      => 1,
228
        "1-1-3-any"           => 3,
228
        "1-1-from_local_hold_group-any"           => 3,
229
        "1-1-3-holdgroup"     => 2,
229
        "1-1-from_local_hold_group-holdgroup"     => 2,
230
        "1-1-3-patrongroup"   => 2,
230
        "1-1-from_local_hold_group-patrongroup"   => 2,
231
        "1-1-3-homebranch"    => 1,
231
        "1-1-from_local_hold_group-homebranch"    => 1,
232
        "1-1-3-holdingbranch" => 1,
232
        "1-1-from_local_hold_group-holdingbranch" => 1,
233
        "1-4-1-any"           => 0,
233
        "1-4-from_home_library-any"               => 0,
234
        "1-4-1-holdgroup"     => 0,
234
        "1-4-from_home_library-holdgroup"         => 0,
235
        "1-4-1-patrongroup"   => 0,
235
        "1-4-from_home_library-patrongroup"       => 0,
236
        "1-4-1-homebranch"    => 0,
236
        "1-4-from_home_library-homebranch"        => 0,
237
        "1-4-1-holdingbranch" => 0,
237
        "1-4-from_home_library-holdingbranch"     => 0,
238
        "1-4-2-any"           => 3,
238
        "1-4-from_any_library-any"                => 3,
239
        "1-4-2-holdgroup"     => 2,
239
        "1-4-from_any_library-holdgroup"          => 2,
240
        "1-4-2-patrongroup"   => 1,
240
        "1-4-from_any_library-patrongroup"        => 1,
241
        "1-4-2-homebranch"    => 1,
241
        "1-4-from_any_library-homebranch"         => 1,
242
        "1-4-2-holdingbranch" => 1,
242
        "1-4-from_any_library-holdingbranch"      => 1,
243
        "1-4-3-any"           => 0,
243
        "1-4-from_local_hold_group-any"           => 0,
244
        "1-4-3-holdgroup"     => 0,
244
        "1-4-from_local_hold_group-holdgroup"     => 0,
245
        "1-4-3-patrongroup"   => 0,
245
        "1-4-from_local_hold_group-patrongroup"   => 0,
246
        "1-4-3-homebranch"    => 0,
246
        "1-4-from_local_hold_group-homebranch"    => 0,
247
        "1-4-3-holdingbranch" => 0,
247
        "1-4-from_local_hold_group-holdingbranch" => 0,
248
        "3-1-1-any"           => 0,
248
        "3-1-from_home_library-any"               => 0,
249
        "3-1-1-holdgroup"     => 0,
249
        "3-1-from_home_library-holdgroup"         => 0,
250
        "3-1-1-patrongroup"   => 0,
250
        "3-1-from_home_library-patrongroup"       => 0,
251
        "3-1-1-homebranch"    => 0,
251
        "3-1-from_home_library-homebranch"        => 0,
252
        "3-1-1-holdingbranch" => 0,
252
        "3-1-from_home_library-holdingbranch"     => 0,
253
        "3-1-2-any"           => 3,
253
        "3-1-from_any_library-any"                => 3,
254
        "3-1-2-holdgroup"     => 1,
254
        "3-1-from_any_library-holdgroup"          => 1,
255
        "3-1-2-patrongroup"   => 2,
255
        "3-1-from_any_library-patrongroup"        => 2,
256
        "3-1-2-homebranch"    => 0,
256
        "3-1-from_any_library-homebranch"         => 0,
257
        "3-1-2-holdingbranch" => 1,
257
        "3-1-from_any_library-holdingbranch"      => 1,
258
        "3-1-3-any"           => 0,
258
        "3-1-from_local_hold_group-any"           => 0,
259
        "3-1-3-holdgroup"     => 0,
259
        "3-1-from_local_hold_group-holdgroup"     => 0,
260
        "3-1-3-patrongroup"   => 0,
260
        "3-1-from_local_hold_group-patrongroup"   => 0,
261
        "3-1-3-homebranch"    => 0,
261
        "3-1-from_local_hold_group-homebranch"    => 0,
262
        "3-1-3-holdingbranch" => 0,
262
        "3-1-from_local_hold_group-holdingbranch" => 0,
263
        "3-4-1-any"           => 0,
263
        "3-4-from_home_library-any"               => 0,
264
        "3-4-1-holdgroup"     => 0,
264
        "3-4-from_home_library-holdgroup"         => 0,
265
        "3-4-1-patrongroup"   => 0,
265
        "3-4-from_home_library-patrongroup"       => 0,
266
        "3-4-1-homebranch"    => 0,
266
        "3-4-from_home_library-homebranch"        => 0,
267
        "3-4-1-holdingbranch" => 0,
267
        "3-4-from_home_library-holdingbranch"     => 0,
268
        "3-4-2-any"           => 3,
268
        "3-4-from_any_library-any"                => 3,
269
        "3-4-2-holdgroup"     => 1,
269
        "3-4-from_any_library-holdgroup"          => 1,
270
        "3-4-2-patrongroup"   => 1,
270
        "3-4-from_any_library-patrongroup"        => 1,
271
        "3-4-2-homebranch"    => 0,
271
        "3-4-from_any_library-homebranch"         => 0,
272
        "3-4-2-holdingbranch" => 1,
272
        "3-4-from_any_library-holdingbranch"      => 1,
273
        "3-4-3-any"           => 3,
273
        "3-4-from_local_hold_group-any"           => 3,
274
        "3-4-3-holdgroup"     => 1,
274
        "3-4-from_local_hold_group-holdgroup"     => 1,
275
        "3-4-3-patrongroup"   => 1,
275
        "3-4-from_local_hold_group-patrongroup"   => 1,
276
        "3-4-3-homebranch"    => 0,
276
        "3-4-from_local_hold_group-homebranch"    => 0,
277
        "3-4-3-holdingbranch" => 1
277
        "3-4-from_local_hold_group-holdingbranch" => 1
278
    };
278
    };
279
279
280
    sub _doTest {
280
    sub _doTest {
Lines 291-297 subtest 'pickup_locations' => sub { Link Here
291
                }
291
                }
292
            }
292
            }
293
        );
293
        );
294
        my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch');
294
        my $ha_value =
295
          $ha eq 'from_local_hold_group' ? 'holdgroup'
296
          : (
297
            $ha eq 'from_any_library' ? 'any'
298
            : 'homebranch'
299
          );
295
300
296
        my @pl = map {
301
        my @pl = map {
297
            my $pickup_location = $_;
302
            my $pickup_location = $_;
Lines 299-305 subtest 'pickup_locations' => sub { Link Here
299
        } $item->pickup_locations( { patron => $patron } )->as_list;
304
        } $item->pickup_locations( { patron => $patron } )->as_list;
300
305
301
        ok(
306
        ok(
302
            scalar(@pl) == $results->{
307
            scalar(@pl) eq $results->{
303
                    $item->copynumber . '-'
308
                    $item->copynumber . '-'
304
                  . $patron->firstname . '-'
309
                  . $patron->firstname . '-'
305
                  . $ha . '-'
310
                  . $ha . '-'
Lines 330-336 subtest 'pickup_locations' => sub { Link Here
330
    foreach my $item ($item1, $item3) {
335
    foreach my $item ($item1, $item3) {
331
        foreach my $patron ($patron1, $patron4) {
336
        foreach my $patron ($patron1, $patron4) {
332
            #holdallowed 1: homebranch, 2: any, 3: holdgroup
337
            #holdallowed 1: homebranch, 2: any, 3: holdgroup
333
            foreach my $ha (1, 2, 3) {
338
            foreach my $ha ('from_home_library', 'from_any_library', 'from_local_hold_group') {
334
                foreach my $hfp ('any', 'holdgroup', 'patrongroup', 'homebranch', 'holdingbranch') {
339
                foreach my $hfp ('any', 'holdgroup', 'patrongroup', 'homebranch', 'holdingbranch') {
335
                    _doTest($item, $patron, $ha, $hfp, $results);
340
                    _doTest($item, $patron, $ha, $hfp, $results);
336
                }
341
                }
Lines 355-361 subtest 'pickup_locations' => sub { Link Here
355
            branchcode => undef,
360
            branchcode => undef,
356
            itemtype   => $item1->itype,
361
            itemtype   => $item1->itype,
357
            rules      => {
362
            rules      => {
358
                holdallowed             => 1,
363
                holdallowed             => 'from_home_library',
359
                hold_fulfillment_policy => 1,
364
                hold_fulfillment_policy => 1,
360
                returnbranch            => 'any'
365
                returnbranch            => 'any'
361
            }
366
            }
(-)a/t/db_dependent/Reserves.t (-2 / +2 lines)
Lines 198-204 Koha::CirculationRules->set_rules( Link Here
198
        branchcode   => $branch_1,
198
        branchcode   => $branch_1,
199
        itemtype     => undef,
199
        itemtype     => undef,
200
        rules        => {
200
        rules        => {
201
            holdallowed  => 1,
201
            holdallowed  => 'from_home_library',
202
            returnbranch => 'homebranch',
202
            returnbranch => 'homebranch',
203
        }
203
        }
204
    }
204
    }
Lines 210-216 Koha::CirculationRules->set_rules( Link Here
210
        branchcode   => $branch_2,
210
        branchcode   => $branch_2,
211
        itemtype     => undef,
211
        itemtype     => undef,
212
        rules        => {
212
        rules        => {
213
            holdallowed  => 2,
213
            holdallowed  => 'from_any_library',
214
            returnbranch => 'homebranch',
214
            returnbranch => 'homebranch',
215
        }
215
        }
216
    }
216
    }
(-)a/t/db_dependent/api/v1/holds.t (-2 / +1 lines)
Lines 365-371 subtest 'test AllowHoldPolicyOverride' => sub { Link Here
365
            itemtype   => undef,
365
            itemtype   => undef,
366
            branchcode => undef,
366
            branchcode => undef,
367
            rules      => {
367
            rules      => {
368
                holdallowed => 1
368
                holdallowed => 'from_home_library'
369
            }
369
            }
370
        }
370
        }
371
    );
371
    );
372
- 

Return to bug 27069