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

(-)a/installer/data/mysql/atomicupdate/bug_22284_add_ft_local_hold_group_to_library_groups.perl (-6 / +1 lines)
Lines 5-16 if( CheckVersion( $DBversion ) ) { Link Here
5
        $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" );
5
        $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" );
6
    }
6
    }
7
7
8
    $dbh->do("ALTER TABLE default_branch_circ_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'");
9
    $dbh->do("ALTER TABLE default_circ_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'");
10
    $dbh->do("ALTER TABLE default_branch_item_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'");
11
    $dbh->do("ALTER TABLE branch_item_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'");
12
13
    # Always end with this (adjust the bug info)
8
    # Always end with this (adjust the bug info)
14
    SetVersion( $DBversion );
9
    SetVersion( $DBversion );
15
    print "Upgrade to $DBversion done (Bug 22284 - Add ft_local_hold_group column to library_groups and alter hold_fulfillment_policy in rules tables)\n";
10
    print "Upgrade to $DBversion done (Bug 22284 - Add ft_local_hold_group column to library_groups)\n";
16
}
11
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-3 / +3 lines)
Lines 437-443 Link Here
437
                                From any library
437
                                From any library
438
                            </option>
438
                            </option>
439
439
440
			    [% IF holdallowed == 3 %]
440
                            [% IF holdallowed == 3 %]
441
                            <option value="3" selected="selected">
441
                            <option value="3" selected="selected">
442
                            [% ELSE %]
442
                            [% ELSE %]
443
                            <option value="3">
443
                            <option value="3">
Lines 480-486 Link Here
480
                                </option>
480
                                </option>
481
                            [% END %]
481
                            [% END %]
482
482
483
			    [% IF hold_fulfillment_policy == 'holdgroup' %]
483
                            [% IF hold_fulfillment_policy == 'holdgroup' %]
484
                                <option value="holdgroup" selected="selected">
484
                                <option value="holdgroup" selected="selected">
485
                                    item's hold group
485
                                    item's hold group
486
                                </option>
486
                                </option>
Lines 753-759 Link Here
753
                            <td>
753
                            <td>
754
                                [% IF holdallowed == 2 %]
754
                                [% IF holdallowed == 2 %]
755
                                    <span>From any library</span>
755
                                    <span>From any library</span>
756
				[% ELSIF holdallowed == 3 %]
756
                                [% ELSIF holdallowed == 3 %]
757
                                    <span>From local hold group</span>
757
                                    <span>From local hold group</span>
758
                                [% ELSIF holdallowed == 1 %]
758
                                [% ELSIF holdallowed == 1 %]
759
                                    <span>From home library</span>
759
                                    <span>From home library</span>
(-)a/t/db_dependent/Holds.t (-99 / +170 lines)
Lines 245-261 my $foreign_biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' }); Link Here
245
my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber)
245
my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber)
246
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_biblio->biblionumber);
246
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_biblio->biblionumber);
247
# Cleanup circulation rules
247
# Cleanup circulation rules
248
$dbh->do('DELETE FROM issuingrules');
248
$dbh->do('DELETE FROM circulation_rules');
249
$dbh->do('DELETE FROM branch_item_rules');
249
# $dbh->do(
250
$dbh->do('DELETE FROM default_branch_item_rules');
250
#     q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
251
$dbh->do('DELETE FROM default_branch_circ_rules');
251
#       VALUES (?, ?, ?, ?, ?)},
252
$dbh->do('DELETE FROM default_circ_rules');
252
#     {},
253
$dbh->do(
253
#     '*', '*', '*', 25, 99
254
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
254
# );
255
      VALUES (?, ?, ?, ?, ?)},
256
    {},
257
    '*', '*', '*', 25, 99
258
);
259
$dbh->do(
255
$dbh->do(
260
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
256
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
261
      VALUES (?, ?, ?, ?, ?)},
257
      VALUES (?, ?, ?, ?, ?)},
Lines 571-580 subtest 'CanItemBeReserved / holds_per_day tests' => sub { Link Here
571
    Koha::Holds->search->delete;
567
    Koha::Holds->search->delete;
572
    $dbh->do('DELETE FROM issues');
568
    $dbh->do('DELETE FROM issues');
573
    $dbh->do('DELETE FROM issuingrules');
569
    $dbh->do('DELETE FROM issuingrules');
574
    $dbh->do('DELETE FROM branch_item_rules');
570
    $dbh->do('DELETE FROM circulation_rules');
575
    $dbh->do('DELETE FROM default_branch_item_rules');
576
    $dbh->do('DELETE FROM default_branch_circ_rules');
577
    $dbh->do('DELETE FROM default_circ_rules');
578
    Koha::Items->search->delete;
571
    Koha::Items->search->delete;
579
    Koha::Biblios->search->delete;
572
    Koha::Biblios->search->delete;
580
573
Lines 715-724 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
715
        {},
708
        {},
716
        '*', '*', '*', 25
709
        '*', '*', '*', 25
717
    );
710
    );
718
    $dbh->do('DELETE FROM branch_item_rules');
711
    $dbh->do('DELETE FROM circulation_rules');
719
    $dbh->do('DELETE FROM default_branch_circ_rules');
720
    $dbh->do('DELETE FROM default_branch_item_rules');
721
    $dbh->do('DELETE FROM default_circ_rules');
722
712
723
    Koha::Items->search->delete;
713
    Koha::Items->search->delete;
724
    Koha::Biblios->search->delete;
714
    Koha::Biblios->search->delete;
Lines 772-782 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
772
    );
762
    );
773
763
774
    # Insert default circ rule of holds allowed only from local hold group for all libraries
764
    # Insert default circ rule of holds allowed only from local hold group for all libraries
775
    $dbh->do(
765
    Koha::CirculationRules->set_rules(
776
        q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch)
766
        {
777
        VALUES (?,?,?)},
767
            branchcode => undef,
778
        {},
768
            itemtype   => undef,
779
        3, 'any', 'any'
769
            categorycode => undef,
770
            rules => {
771
                holdallowed => 3,
772
                hold_fulfillment_policy => 'any',
773
                returnbranch => 'any'
774
            }
775
        }
780
    );
776
    );
781
777
782
    # Test 2: Patron 1 can place hold
778
    # Test 2: Patron 1 can place hold
Lines 794-807 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
794
    );
790
    );
795
791
796
    # Cleanup default_cirt_rules
792
    # Cleanup default_cirt_rules
797
    $dbh->do('DELETE FROM default_circ_rules');
793
    $dbh->do('DELETE FROM circulation_rules');
798
794
799
    # Insert default circ rule to "any" for library 2
795
    # Insert default circ rule to "any" for library 2
800
    $dbh->do(
796
    Koha::CirculationRules->set_rules(
801
        q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
797
        {
802
        VALUES (?,?,?,?)},
798
            branchcode => $library2->branchcode,
803
        {},
799
            itemtype   => undef,
804
        $library2->branchcode, 2, 'any', 'any'
800
            categorycode => undef,
801
            rules => {
802
                holdallowed => 2,
803
                hold_fulfillment_policy => 'any',
804
                returnbranch => 'any'
805
            }
806
        }
805
    );
807
    );
806
808
807
    # Test 4: Patron 3 can place hold
809
    # Test 4: Patron 3 can place hold
Lines 812-822 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
812
    );
814
    );
813
815
814
    # Update default circ rule to "hold group" for library 2
816
    # Update default circ rule to "hold group" for library 2
815
    $dbh->do(
817
    Koha::CirculationRules->set_rules(
816
        q{UPDATE default_branch_circ_rules set holdallowed = ?
818
        {
817
        WHERE branchcode = ?},
819
            branchcode => $library2->branchcode,
818
        {},
820
            itemtype   => undef,
819
        3, $library2->branchcode
821
            categorycode => undef,
822
            rules => {
823
                holdallowed => 3,
824
                hold_fulfillment_policy => 'any',
825
                returnbranch => 'any'
826
            }
827
        }
820
    );
828
    );
821
829
822
    # Test 5: Patron 3 cannot place hold
830
    # Test 5: Patron 3 cannot place hold
Lines 827-840 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
827
    );
835
    );
828
836
829
    # Cleanup default_branch_cirt_rules
837
    # Cleanup default_branch_cirt_rules
830
    $dbh->do('DELETE FROM default_branch_circ_rules');
838
    $dbh->do('DELETE FROM circulation_rules');
831
839
832
    # Insert default item rule to "any" for itemtype 2
840
    # Insert default item rule to "any" for itemtype 2
833
    $dbh->do(
841
    Koha::CirculationRules->set_rules(
834
        q{INSERT INTO default_branch_item_rules (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
842
        {
835
        VALUES (?,?,?,?)},
843
            branchcode => undef,
836
        {},
844
            itemtype   => $itemtype2->itemtype,
837
        $itemtype2->itemtype, 2, 'any', 'any'
845
            categorycode => undef,
846
            rules => {
847
                holdallowed => 2,
848
                hold_fulfillment_policy => 'any',
849
                returnbranch => 'any'
850
            }
851
        }
838
    );
852
    );
839
853
840
    # Test 6: Patron 3 can place hold
854
    # Test 6: Patron 3 can place hold
Lines 845-855 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
845
    );
859
    );
846
860
847
    # Update default item rule to "hold group" for itemtype 2
861
    # Update default item rule to "hold group" for itemtype 2
848
    $dbh->do(
862
    Koha::CirculationRules->set_rules(
849
        q{UPDATE default_branch_item_rules set holdallowed = ?
863
        {
850
        WHERE itemtype = ?},
864
            branchcode => undef,
851
        {},
865
            itemtype   => $itemtype2->itemtype,
852
        3, $itemtype2->itemtype
866
            categorycode => undef,
867
            rules => {
868
                holdallowed => 3,
869
                hold_fulfillment_policy => 'any',
870
                returnbranch => 'any'
871
            }
872
        }
853
    );
873
    );
854
874
855
    # Test 7: Patron 3 cannot place hold
875
    # Test 7: Patron 3 cannot place hold
Lines 860-873 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
860
    );
880
    );
861
881
862
    # Cleanup default_branch_item_rules
882
    # Cleanup default_branch_item_rules
863
    $dbh->do('DELETE FROM default_branch_item_rules');
883
    $dbh->do('DELETE FROM circulation_rules');
864
884
865
    # Insert branch item rule to "any" for itemtype 2 and library 2
885
    # Insert branch item rule to "any" for itemtype 2 and library 2
866
    $dbh->do(
886
    Koha::CirculationRules->set_rules(
867
        q{INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
887
        {
868
        VALUES (?,?,?,?,?)},
888
            branchcode => $library2->branchcode,
869
        {},
889
            itemtype   => $itemtype2->itemtype,
870
        $library2->branchcode, $itemtype2->itemtype, 2, 'any', 'any'
890
            categorycode => undef,
891
            rules => {
892
                holdallowed => 2,
893
                hold_fulfillment_policy => 'any',
894
                returnbranch => 'any'
895
            }
896
        }
871
    );
897
    );
872
898
873
    # Test 8: Patron 3 can place hold
899
    # Test 8: Patron 3 can place hold
Lines 878-888 subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { Link Here
878
    );
904
    );
879
905
880
    # Update branch item rule to "hold group" for itemtype 2 and library 2
906
    # Update branch item rule to "hold group" for itemtype 2 and library 2
881
    $dbh->do(
907
    Koha::CirculationRules->set_rules(
882
        q{UPDATE branch_item_rules set holdallowed = ?
908
        {
883
        WHERE branchcode = ? and itemtype = ?},
909
            branchcode => $library2->branchcode,
884
        {},
910
            itemtype   => $itemtype2->itemtype,
885
        3, $library2->branchcode, $itemtype2->itemtype
911
            categorycode => undef,
912
            rules => {
913
                holdallowed => 3,
914
                hold_fulfillment_policy => 'any',
915
                returnbranch => 'any'
916
            }
917
        }
886
    );
918
    );
887
919
888
    # Test 9: Patron 3 cannot place hold
920
    # Test 9: Patron 3 cannot place hold
Lines 911-920 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
911
        {},
943
        {},
912
        '*', '*', '*', 25
944
        '*', '*', '*', 25
913
    );
945
    );
914
    $dbh->do('DELETE FROM branch_item_rules');
946
    $dbh->do('DELETE FROM circulation_rules');
915
    $dbh->do('DELETE FROM default_branch_circ_rules');
916
    $dbh->do('DELETE FROM default_branch_item_rules');
917
    $dbh->do('DELETE FROM default_circ_rules');
918
947
919
    Koha::Items->search->delete;
948
    Koha::Items->search->delete;
920
    Koha::Biblios->search->delete;
949
    Koha::Biblios->search->delete;
Lines 968-978 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
968
    );
997
    );
969
998
970
    # Insert default circ rule of holds allowed only from local hold group for all libraries
999
    # Insert default circ rule of holds allowed only from local hold group for all libraries
971
    $dbh->do(
1000
    Koha::CirculationRules->set_rules(
972
        q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch)
1001
        {
973
        VALUES (?,?,?)},
1002
            branchcode => undef,
974
        {},
1003
            itemtype   => undef,
975
        2, 'holdgroup', 'any'
1004
            categorycode => undef,
1005
            rules => {
1006
                holdallowed => 2,
1007
                hold_fulfillment_policy => 'holdgroup',
1008
                returnbranch => 'any'
1009
            }
1010
        }
976
    );
1011
    );
977
1012
978
    # Test 2: Patron 1 can place hold
1013
    # Test 2: Patron 1 can place hold
Lines 990-1003 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
990
    );
1025
    );
991
1026
992
    # Cleanup default_cirt_rules
1027
    # Cleanup default_cirt_rules
993
    $dbh->do('DELETE FROM default_circ_rules');
1028
    $dbh->do('DELETE FROM circulation_rules');
994
1029
995
    # Insert default circ rule to "any" for library 2
1030
    # Insert default circ rule to "any" for library 2
996
    $dbh->do(
1031
    Koha::CirculationRules->set_rules(
997
        q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, hold_fulfillment_policy, returnbranch)
1032
        {
998
        VALUES (?,?,?,?)},
1033
            branchcode => $library2->branchcode,
999
        {},
1034
            itemtype   => undef,
1000
        $library2->branchcode, 2, 'any', 'any'
1035
            categorycode => undef,
1036
            rules => {
1037
                holdallowed => 2,
1038
                hold_fulfillment_policy => 'any',
1039
                returnbranch => 'any'
1040
            }
1041
        }
1001
    );
1042
    );
1002
1043
1003
    # Test 4: Patron 3 can place hold
1044
    # Test 4: Patron 3 can place hold
Lines 1008-1018 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1008
    );
1049
    );
1009
1050
1010
    # Update default circ rule to "hold group" for library 2
1051
    # Update default circ rule to "hold group" for library 2
1011
    $dbh->do(
1052
    Koha::CirculationRules->set_rules(
1012
        q{UPDATE default_branch_circ_rules set hold_fulfillment_policy = ?
1053
        {
1013
        WHERE branchcode = ?},
1054
            branchcode => $library2->branchcode,
1014
        {},
1055
            itemtype   => undef,
1015
        'holdgroup', $library2->branchcode
1056
            categorycode => undef,
1057
            rules => {
1058
                holdallowed => 2,
1059
                hold_fulfillment_policy => 'holdgroup',
1060
                returnbranch => 'any'
1061
            }
1062
        }
1016
    );
1063
    );
1017
1064
1018
    # Test 5: Patron 3 cannot place hold
1065
    # Test 5: Patron 3 cannot place hold
Lines 1023-1036 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1023
    );
1070
    );
1024
1071
1025
    # Cleanup default_branch_cirt_rules
1072
    # Cleanup default_branch_cirt_rules
1026
    $dbh->do('DELETE FROM default_branch_circ_rules');
1073
    $dbh->do('DELETE FROM circulation_rules');
1027
1074
1028
    # Insert default item rule to "any" for itemtype 2
1075
    # Insert default item rule to "any" for itemtype 2
1029
    $dbh->do(
1076
    Koha::CirculationRules->set_rules(
1030
        q{INSERT INTO default_branch_item_rules (itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
1077
        {
1031
        VALUES (?,?,?,?)},
1078
            branchcode => undef,
1032
        {},
1079
            itemtype   => $itemtype2->itemtype,
1033
        $itemtype2->itemtype, 2, 'any', 'any'
1080
            categorycode => undef,
1081
            rules => {
1082
                holdallowed => 2,
1083
                hold_fulfillment_policy => 'any',
1084
                returnbranch => 'any'
1085
            }
1086
        }
1034
    );
1087
    );
1035
1088
1036
    # Test 6: Patron 3 can place hold
1089
    # Test 6: Patron 3 can place hold
Lines 1041-1051 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1041
    );
1094
    );
1042
1095
1043
    # Update default item rule to "hold group" for itemtype 2
1096
    # Update default item rule to "hold group" for itemtype 2
1044
    $dbh->do(
1097
    Koha::CirculationRules->set_rules(
1045
        q{UPDATE default_branch_item_rules set hold_fulfillment_policy = ?
1098
        {
1046
        WHERE itemtype = ?},
1099
            branchcode => undef,
1047
        {},
1100
            itemtype   => $itemtype2->itemtype,
1048
        'holdgroup', $itemtype2->itemtype
1101
            categorycode => undef,
1102
            rules => {
1103
                holdallowed => 2,
1104
                hold_fulfillment_policy => 'holdgroup',
1105
                returnbranch => 'any'
1106
            }
1107
        }
1049
    );
1108
    );
1050
1109
1051
    # Test 7: Patron 3 cannot place hold
1110
    # Test 7: Patron 3 cannot place hold
Lines 1056-1069 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1056
    );
1115
    );
1057
1116
1058
    # Cleanup default_branch_item_rules
1117
    # Cleanup default_branch_item_rules
1059
    $dbh->do('DELETE FROM default_branch_item_rules');
1118
    $dbh->do('DELETE FROM circulation_rules');
1060
1119
1061
    # Insert branch item rule to "any" for itemtype 2 and library 2
1120
    # Insert branch item rule to "any" for itemtype 2 and library 2
1062
    $dbh->do(
1121
    Koha::CirculationRules->set_rules(
1063
        q{INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch)
1122
        {
1064
        VALUES (?,?,?,?,?)},
1123
            branchcode => $library2->branchcode,
1065
        {},
1124
            itemtype   => $itemtype2->itemtype,
1066
        $library2->branchcode, $itemtype2->itemtype, 2, 'any', 'any'
1125
            categorycode => undef,
1126
            rules => {
1127
                holdallowed => 2,
1128
                hold_fulfillment_policy => 'any',
1129
                returnbranch => 'any'
1130
            }
1131
        }
1067
    );
1132
    );
1068
1133
1069
    # Test 8: Patron 3 can place hold
1134
    # Test 8: Patron 3 can place hold
Lines 1074-1084 subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { Link Here
1074
    );
1139
    );
1075
1140
1076
    # Update branch item rule to "hold group" for itemtype 2 and library 2
1141
    # Update branch item rule to "hold group" for itemtype 2 and library 2
1077
    $dbh->do(
1142
    Koha::CirculationRules->set_rules(
1078
        q{UPDATE branch_item_rules set hold_fulfillment_policy = ?
1143
        {
1079
        WHERE branchcode = ? and itemtype = ?},
1144
            branchcode => $library2->branchcode,
1080
        {},
1145
            itemtype   => $itemtype2->itemtype,
1081
        'holdgroup', $library2->branchcode, $itemtype2->itemtype
1146
            categorycode => undef,
1147
            rules => {
1148
                holdallowed => 2,
1149
                hold_fulfillment_policy => 'holdgroup',
1150
                returnbranch => 'any'
1151
            }
1152
        }
1082
    );
1153
    );
1083
1154
1084
    # Test 9: Patron 3 cannot place hold
1155
    # Test 9: Patron 3 cannot place hold
(-)a/t/db_dependent/Koha/Biblios.t (-69 / +177 lines)
Lines 209-218 subtest 'pickup_locations' => sub { Link Here
209
        {},
209
        {},
210
        '*', '*', '*', 25
210
        '*', '*', '*', 25
211
    );
211
    );
212
    $dbh->do('DELETE FROM branch_item_rules');
212
    $dbh->do('DELETE FROM circulation_rules');
213
    $dbh->do('DELETE FROM default_branch_circ_rules');
214
    $dbh->do('DELETE FROM default_branch_item_rules');
215
    $dbh->do('DELETE FROM default_circ_rules');
216
213
217
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
214
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
218
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
215
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
Lines 290-300 subtest 'pickup_locations' => sub { Link Here
290
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
287
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
291
288
292
    #Case 1: holdallowed any, hold_fulfillment_policy any
289
    #Case 1: holdallowed any, hold_fulfillment_policy any
293
    $dbh->do(
290
    Koha::CirculationRules->set_rules(
294
        q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch)
291
        {
295
        VALUES (?,?,?)},
292
            branchcode => undef,
296
        {},
293
            itemtype   => undef,
297
        2, 'any', 'any'
294
            categorycode => undef,
295
            rules => {
296
                holdallowed => 2,
297
                hold_fulfillment_policy => 'any',
298
                returnbranch => 'any'
299
            }
300
        }
298
    );
301
    );
299
302
300
    my @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
303
    my @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 306-315 subtest 'pickup_locations' => sub { Link Here
306
    ok(scalar(@pl_1_1) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5 && scalar(@pl_2_4) == 5, 'Returns all libraries that are pickup locations');
309
    ok(scalar(@pl_1_1) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5 && scalar(@pl_2_4) == 5, 'Returns all libraries that are pickup locations');
307
310
308
    #Case 2: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'homebranch'
311
    #Case 2: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'homebranch'
309
    $dbh->do(
312
    Koha::CirculationRules->set_rules(
310
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
313
        {
311
        {},
314
            branchcode => undef,
312
        1, 'any'
315
            itemtype   => undef,
316
            categorycode => undef,
317
            rules => {
318
                holdallowed => 1,
319
                hold_fulfillment_policy => 'any',
320
                returnbranch => 'any'
321
            }
322
        }
313
    );
323
    );
314
324
315
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
325
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 321-330 subtest 'pickup_locations' => sub { Link Here
321
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations');
331
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations');
322
332
323
    #Case 3: holdallowed holdgroup, hold_fulfillment_policy any
333
    #Case 3: holdallowed holdgroup, hold_fulfillment_policy any
324
    $dbh->do(
334
    Koha::CirculationRules->set_rules(
325
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
335
        {
326
        {},
336
            branchcode => undef,
327
        3, 'any'
337
            itemtype   => undef,
338
            categorycode => undef,
339
            rules => {
340
                holdallowed => 3,
341
                hold_fulfillment_policy => 'any',
342
                returnbranch => 'any'
343
            }
344
        }
328
    );
345
    );
329
346
330
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
347
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 335-344 subtest 'pickup_locations' => sub { Link Here
335
    ok(scalar(@pl_1_1) == 5 && scalar(@pl_2_4) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5, 'Returns all libraries that are pickup_locations, when item\'s hombebranch is in patron\' holdgroup');
352
    ok(scalar(@pl_1_1) == 5 && scalar(@pl_2_4) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5, 'Returns all libraries that are pickup_locations, when item\'s hombebranch is in patron\' holdgroup');
336
353
337
    #Case 4: holdallowed any, hold_fulfillment_policy holdgroup
354
    #Case 4: holdallowed any, hold_fulfillment_policy holdgroup
338
    $dbh->do(
355
    Koha::CirculationRules->set_rules(
339
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
356
        {
340
        {},
357
            branchcode => undef,
341
        2, 'holdgroup'
358
            itemtype   => undef,
359
            categorycode => undef,
360
            rules => {
361
                holdallowed => 2,
362
                hold_fulfillment_policy => 'holdgroup',
363
                returnbranch => 'any'
364
            }
365
        }
342
    );
366
    );
343
367
344
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
368
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 349-358 subtest 'pickup_locations' => sub { Link Here
349
    ok(scalar(@pl_1_1) == 3 && scalar(@pl_2_4) == 3 && scalar(@pl_1_4) == 3 && scalar(@pl_2_1) == 3, 'Returns libraries in item\'s holdgroup, and that are pickup_locations');
373
    ok(scalar(@pl_1_1) == 3 && scalar(@pl_2_4) == 3 && scalar(@pl_1_4) == 3 && scalar(@pl_2_1) == 3, 'Returns libraries in item\'s holdgroup, and that are pickup_locations');
350
374
351
    #Case 5: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'homebranch'
375
    #Case 5: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'homebranch'
352
    $dbh->do(
376
    Koha::CirculationRules->set_rules(
353
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
377
        {
354
        {},
378
            branchcode => undef,
355
        1, 'holdgroup'
379
            itemtype   => undef,
380
            categorycode => undef,
381
            rules => {
382
                holdallowed => 1,
383
                hold_fulfillment_policy => 'holdgroup',
384
                returnbranch => 'any'
385
            }
386
        }
356
    );
387
    );
357
388
358
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
389
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 364-373 subtest 'pickup_locations' => sub { Link Here
364
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations');
395
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations');
365
396
366
    #Case 6: holdallowed holdgroup, hold_fulfillment_policy holdgroup
397
    #Case 6: holdallowed holdgroup, hold_fulfillment_policy holdgroup
367
    $dbh->do(
398
    Koha::CirculationRules->set_rules(
368
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
399
        {
369
        {},
400
            branchcode => undef,
370
        3, 'holdgroup'
401
            itemtype   => undef,
402
            categorycode => undef,
403
            rules => {
404
                holdallowed => 3,
405
                hold_fulfillment_policy => 'holdgroup',
406
                returnbranch => 'any'
407
            }
408
        }
371
    );
409
    );
372
410
373
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
411
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 378-387 subtest 'pickup_locations' => sub { Link Here
378
    ok(scalar(@pl_1_1) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 1 && scalar(@pl_1_4) == 1, 'Returns libraries in item\'s holdgroup whose homebranch is included patron\'s holdgroup, and that are pickup_locations');
416
    ok(scalar(@pl_1_1) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 1 && scalar(@pl_1_4) == 1, 'Returns libraries in item\'s holdgroup whose homebranch is included patron\'s holdgroup, and that are pickup_locations');
379
417
380
    #Case 7: holdallowed any, hold_fulfillment_policy homebranch
418
    #Case 7: holdallowed any, hold_fulfillment_policy homebranch
381
    $dbh->do(
419
    Koha::CirculationRules->set_rules(
382
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
420
        {
383
        {},
421
            branchcode => undef,
384
        2, 'homebranch'
422
            itemtype   => undef,
423
            categorycode => undef,
424
            rules => {
425
                holdallowed => 2,
426
                hold_fulfillment_policy => 'homebranch',
427
                returnbranch => 'any'
428
            }
429
        }
385
    );
430
    );
386
431
387
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
432
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 392-401 subtest 'pickup_locations' => sub { Link Here
392
    ok(scalar(@pl_1_1) == 1 && scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns homebranch of items in biblio, that are pickup_locations');
437
    ok(scalar(@pl_1_1) == 1 && scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns homebranch of items in biblio, that are pickup_locations');
393
438
394
    #Case 8: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'homebranch'
439
    #Case 8: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'homebranch'
395
    $dbh->do(
440
    Koha::CirculationRules->set_rules(
396
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
441
        {
397
        {},
442
            branchcode => undef,
398
        1, 'homebranch'
443
            itemtype   => undef,
444
            categorycode => undef,
445
            rules => {
446
                holdallowed => 1,
447
                hold_fulfillment_policy => 'homebranch',
448
                returnbranch => 'any'
449
            }
450
        }
399
    );
451
    );
400
452
401
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
453
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 407-416 subtest 'pickup_locations' => sub { Link Here
407
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned');
459
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned');
408
460
409
    #Case 9: holdallowed holdgroup, hold_fulfillment_policy homebranch
461
    #Case 9: holdallowed holdgroup, hold_fulfillment_policy homebranch
410
    $dbh->do(
462
    Koha::CirculationRules->set_rules(
411
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
463
        {
412
        {},
464
            branchcode => undef,
413
        3, 'homebranch'
465
            itemtype   => undef,
466
            categorycode => undef,
467
            rules => {
468
                holdallowed => 3,
469
                hold_fulfillment_policy => 'homebranch',
470
                returnbranch => 'any'
471
            }
472
        }
414
    );
473
    );
415
474
416
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
475
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 422-431 subtest 'pickup_locations' => sub { Link Here
422
    ok(scalar(@pl_1_4) == 0, 'No pickup locations returned');
481
    ok(scalar(@pl_1_4) == 0, 'No pickup locations returned');
423
482
424
    #Case 10: holdallowed any, hold_fulfillment_policy holdingbranch
483
    #Case 10: holdallowed any, hold_fulfillment_policy holdingbranch
425
    $dbh->do(
484
    Koha::CirculationRules->set_rules(
426
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
485
        {
427
        {},
486
            branchcode => undef,
428
        2, 'holdingbranch'
487
            itemtype   => undef,
488
            categorycode => undef,
489
            rules => {
490
                holdallowed => 2,
491
                hold_fulfillment_policy => 'holdingbranch',
492
                returnbranch => 'any'
493
            }
494
        }
429
    );
495
    );
430
496
431
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
497
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 436-445 subtest 'pickup_locations' => sub { Link Here
436
    ok(scalar(@pl_1_1) == 2 && scalar(@pl_1_4) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns holdingbranch of items in biblio, that are pickup_locations');
502
    ok(scalar(@pl_1_1) == 2 && scalar(@pl_1_4) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns holdingbranch of items in biblio, that are pickup_locations');
437
503
438
    #Case 11: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'homebranch'
504
    #Case 11: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'homebranch'
439
    $dbh->do(
505
    Koha::CirculationRules->set_rules(
440
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
506
        {
441
        {},
507
            branchcode => undef,
442
        1, 'holdingbranch'
508
            itemtype   => undef,
509
            categorycode => undef,
510
            rules => {
511
                holdallowed => 1,
512
                hold_fulfillment_policy => 'holdingbranch',
513
                returnbranch => 'any'
514
            }
515
        }
443
    );
516
    );
444
517
445
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
518
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 451-460 subtest 'pickup_locations' => sub { Link Here
451
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned');
524
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned');
452
525
453
    #Case 12: holdallowed holdgroup, hold_fulfillment_policy holdingbranch
526
    #Case 12: holdallowed holdgroup, hold_fulfillment_policy holdingbranch
454
    $dbh->do(
527
    Koha::CirculationRules->set_rules(
455
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
528
        {
456
        {},
529
            branchcode => undef,
457
        3, 'holdingbranch'
530
            itemtype   => undef,
531
            categorycode => undef,
532
            rules => {
533
                holdallowed => 3,
534
                hold_fulfillment_policy => 'holdingbranch',
535
                returnbranch => 'any'
536
            }
537
        }
458
    );
538
    );
459
539
460
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
540
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 467-476 subtest 'pickup_locations' => sub { Link Here
467
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch');
547
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch');
468
548
469
    #Case 13: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'holdingbranch'
549
    #Case 13: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'holdingbranch'
470
    $dbh->do(
550
    Koha::CirculationRules->set_rules(
471
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
551
        {
472
        {},
552
            branchcode => undef,
473
        1, 'any'
553
            itemtype   => undef,
554
            categorycode => undef,
555
            rules => {
556
                holdallowed => 1,
557
                hold_fulfillment_policy => 'any',
558
                returnbranch => 'any'
559
            }
560
        }
474
    );
561
    );
475
562
476
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
563
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 482-491 subtest 'pickup_locations' => sub { Link Here
482
    ok(scalar(@pl_1_1) == 0, 'No pickup locations returned');
569
    ok(scalar(@pl_1_1) == 0, 'No pickup locations returned');
483
570
484
    #Case 14: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'holdingbranch'
571
    #Case 14: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'holdingbranch'
485
    $dbh->do(
572
    Koha::CirculationRules->set_rules(
486
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
573
        {
487
        {},
574
            branchcode => undef,
488
        1, 'holdgroup'
575
            itemtype   => undef,
576
            categorycode => undef,
577
            rules => {
578
                holdallowed => 1,
579
                hold_fulfillment_policy => 'holdgroup',
580
                returnbranch => 'any'
581
            }
582
        }
489
    );
583
    );
490
584
491
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
585
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 497-506 subtest 'pickup_locations' => sub { Link Here
497
    ok(scalar(@pl_1_1) == 0, 'No pickup locations returned');
591
    ok(scalar(@pl_1_1) == 0, 'No pickup locations returned');
498
592
499
    #Case 15: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'holdingbranch'
593
    #Case 15: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'holdingbranch'
500
    $dbh->do(
594
    Koha::CirculationRules->set_rules(
501
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
595
        {
502
        {},
596
            branchcode => undef,
503
        1, 'homebranch'
597
            itemtype   => undef,
598
            categorycode => undef,
599
            rules => {
600
                holdallowed => 1,
601
                hold_fulfillment_policy => 'homebranch',
602
                returnbranch => 'any'
603
            }
604
        }
504
    );
605
    );
505
606
506
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
607
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
Lines 513-522 subtest 'pickup_locations' => sub { Link Here
513
    ok(scalar(@pl_1_1) == 0 && scalar(@pl_1_4) == 0, 'No pickup locations returned');
614
    ok(scalar(@pl_1_1) == 0 && scalar(@pl_1_4) == 0, 'No pickup locations returned');
514
615
515
    #Case 16: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'holdingbranch'
616
    #Case 16: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'holdingbranch'
516
    $dbh->do(
617
    Koha::CirculationRules->set_rules(
517
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
618
        {
518
        {},
619
            branchcode => undef,
519
        1, 'holdingbranch'
620
            itemtype   => undef,
621
            categorycode => undef,
622
            rules => {
623
                holdallowed => 1,
624
                hold_fulfillment_policy => 'holdingbranch',
625
                returnbranch => 'any'
626
            }
627
        }
520
    );
628
    );
521
629
522
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
630
    @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } );
(-)a/t/db_dependent/Koha/Items.t (-69 / +177 lines)
Lines 186-195 subtest 'pickup_locations' => sub { Link Here
186
        {},
186
        {},
187
        '*', '*', '*', 25
187
        '*', '*', '*', 25
188
    );
188
    );
189
    $dbh->do('DELETE FROM branch_item_rules');
189
    $dbh->do('DELETE FROM circulation_rules');
190
    $dbh->do('DELETE FROM default_branch_circ_rules');
191
    $dbh->do('DELETE FROM default_branch_item_rules');
192
    $dbh->do('DELETE FROM default_circ_rules');
193
190
194
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
191
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
195
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
192
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
Lines 231-241 subtest 'pickup_locations' => sub { Link Here
231
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
228
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
232
229
233
    #Case 1: holdallowed any, hold_fulfillment_policy any
230
    #Case 1: holdallowed any, hold_fulfillment_policy any
234
    $dbh->do(
231
    Koha::CirculationRules->set_rules(
235
        q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch)
232
        {
236
        VALUES (?,?,?)},
233
            branchcode => undef,
237
        {},
234
            itemtype   => undef,
238
        2, 'any', 'any'
235
            categorycode => undef,
236
            rules => {
237
                holdallowed => 2,
238
                hold_fulfillment_policy => 'any',
239
                returnbranch => 'any'
240
            }
241
        }
239
    );
242
    );
240
243
241
    my @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
244
    my @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 246-255 subtest 'pickup_locations' => sub { Link Here
246
    ok(scalar(@pl_1_1) == scalar(@pl_1_4) && scalar(@pl_1_1) == scalar(@pl_3_1) && scalar(@pl_1_1) == scalar(@pl_3_4), 'All combinations of patron/item renders the same number of locations');
249
    ok(scalar(@pl_1_1) == scalar(@pl_1_4) && scalar(@pl_1_1) == scalar(@pl_3_1) && scalar(@pl_1_1) == scalar(@pl_3_4), 'All combinations of patron/item renders the same number of locations');
247
250
248
    #Case 2: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'homebranch'
251
    #Case 2: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'homebranch'
249
    $dbh->do(
252
    Koha::CirculationRules->set_rules(
250
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
253
        {
251
        {},
254
            branchcode => undef,
252
        1, 'any'
255
            itemtype   => undef,
256
            categorycode => undef,
257
            rules => {
258
                holdallowed => 1,
259
                hold_fulfillment_policy => 'any',
260
                returnbranch => 'any'
261
            }
262
        }
253
    );
263
    );
254
264
255
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
265
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 261-270 subtest 'pickup_locations' => sub { Link Here
261
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
271
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
262
272
263
    #Case 3: holdallowed holdgroup, hold_fulfillment_policy any
273
    #Case 3: holdallowed holdgroup, hold_fulfillment_policy any
264
    $dbh->do(
274
    Koha::CirculationRules->set_rules(
265
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
275
        {
266
        {},
276
            branchcode => undef,
267
        3, 'any'
277
            itemtype   => undef,
278
            categorycode => undef,
279
            rules => {
280
                holdallowed => 3,
281
                hold_fulfillment_policy => 'any',
282
                returnbranch => 'any'
283
            }
284
        }
268
    );
285
    );
269
286
270
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
287
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 277-286 subtest 'pickup_locations' => sub { Link Here
277
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0, 'Any other combination renders no locations');
294
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0, 'Any other combination renders no locations');
278
295
279
    #Case 4: holdallowed any, hold_fulfillment_policy holdgroup
296
    #Case 4: holdallowed any, hold_fulfillment_policy holdgroup
280
    $dbh->do(
297
    Koha::CirculationRules->set_rules(
281
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
298
        {
282
        {},
299
            branchcode => undef,
283
        2, 'holdgroup'
300
            itemtype   => undef,
301
            categorycode => undef,
302
            rules => {
303
                holdallowed => 2,
304
                hold_fulfillment_policy => 'holdgroup',
305
                returnbranch => 'any'
306
            }
307
        }
284
    );
308
    );
285
309
286
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
310
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 292-301 subtest 'pickup_locations' => sub { Link Here
292
    ok(scalar(@pl_3_1) == 1 && scalar(@pl_3_4) == 1, 'Pickup locations for item 3 renders all libraries in items\'s holdgroup that are pickup_locations');
316
    ok(scalar(@pl_3_1) == 1 && scalar(@pl_3_4) == 1, 'Pickup locations for item 3 renders all libraries in items\'s holdgroup that are pickup_locations');
293
317
294
    #Case 5: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'homebranch'
318
    #Case 5: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'homebranch'
295
    $dbh->do(
319
    Koha::CirculationRules->set_rules(
296
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
320
        {
297
        {},
321
            branchcode => undef,
298
        1, 'holdgroup'
322
            itemtype   => undef,
323
            categorycode => undef,
324
            rules => {
325
                holdallowed => 1,
326
                hold_fulfillment_policy => 'holdgroup',
327
                returnbranch => 'any'
328
            }
329
        }
299
    );
330
    );
300
331
301
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
332
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 307-316 subtest 'pickup_locations' => sub { Link Here
307
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
338
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
308
339
309
    #Case 6: holdallowed holdgroup, hold_fulfillment_policy holdgroup
340
    #Case 6: holdallowed holdgroup, hold_fulfillment_policy holdgroup
310
    $dbh->do(
341
    Koha::CirculationRules->set_rules(
311
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
342
        {
312
        {},
343
            branchcode => undef,
313
        3, 'holdgroup'
344
            itemtype   => undef,
345
            categorycode => undef,
346
            rules => {
347
                holdallowed => 3,
348
                hold_fulfillment_policy => 'holdgroup',
349
                returnbranch => 'any'
350
            }
351
        }
314
    );
352
    );
315
353
316
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
354
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 323-332 subtest 'pickup_locations' => sub { Link Here
323
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0, 'Any other combination renders no locations');
361
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0, 'Any other combination renders no locations');
324
362
325
    #Case 7: holdallowed any, hold_fulfillment_policy homebranch
363
    #Case 7: holdallowed any, hold_fulfillment_policy homebranch
326
    $dbh->do(
364
    Koha::CirculationRules->set_rules(
327
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
365
        {
328
        {},
366
            branchcode => undef,
329
        2, 'homebranch'
367
            itemtype   => undef,
368
            categorycode => undef,
369
            rules => {
370
                holdallowed => 2,
371
                hold_fulfillment_policy => 'homebranch',
372
                returnbranch => 'any'
373
            }
374
        }
330
    );
375
    );
331
376
332
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
377
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 338-347 subtest 'pickup_locations' => sub { Link Here
338
    ok(scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations, because library3 is not pickup_location');
383
    ok(scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations, because library3 is not pickup_location');
339
384
340
    #Case 8: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'homebranch'
385
    #Case 8: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'homebranch'
341
    $dbh->do(
386
    Koha::CirculationRules->set_rules(
342
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
387
        {
343
        {},
388
            branchcode => undef,
344
        1, 'homebranch'
389
            itemtype   => undef,
390
            categorycode => undef,
391
            rules => {
392
                holdallowed => 1,
393
                hold_fulfillment_policy => 'homebranch',
394
                returnbranch => 'any'
395
            }
396
        }
345
    );
397
    );
346
398
347
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
399
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 353-362 subtest 'pickup_locations' => sub { Link Here
353
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
405
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
354
406
355
    #Case 9: holdallowed holdgroup, hold_fulfillment_policy homebranch
407
    #Case 9: holdallowed holdgroup, hold_fulfillment_policy homebranch
356
    $dbh->do(
408
    Koha::CirculationRules->set_rules(
357
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
409
        {
358
        {},
410
            branchcode => undef,
359
        3, 'homebranch'
411
            itemtype   => undef,
412
            categorycode => undef,
413
            rules => {
414
                holdallowed => 3,
415
                hold_fulfillment_policy => 'homebranch',
416
                returnbranch => 'any'
417
            }
418
        }
360
    );
419
    );
361
420
362
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
421
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 368-377 subtest 'pickup_locations' => sub { Link Here
368
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
427
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
369
428
370
    #Case 10: holdallowed any, hold_fulfillment_policy holdingbranch
429
    #Case 10: holdallowed any, hold_fulfillment_policy holdingbranch
371
    $dbh->do(
430
    Koha::CirculationRules->set_rules(
372
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
431
        {
373
        {},
432
            branchcode => undef,
374
        2, 'holdingbranch'
433
            itemtype   => undef,
434
            categorycode => undef,
435
            rules => {
436
                holdallowed => 2,
437
                hold_fulfillment_policy => 'holdingbranch',
438
                returnbranch => 'any'
439
            }
440
        }
375
    );
441
    );
376
442
377
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
443
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 384-393 subtest 'pickup_locations' => sub { Link Here
384
450
385
451
386
    #Case 11: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'homebranch'
452
    #Case 11: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'homebranch'
387
    $dbh->do(
453
    Koha::CirculationRules->set_rules(
388
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
454
        {
389
        {},
455
            branchcode => undef,
390
        1, 'holdingbranch'
456
            itemtype   => undef,
457
            categorycode => undef,
458
            rules => {
459
                holdallowed => 1,
460
                hold_fulfillment_policy => 'holdingbranch',
461
                returnbranch => 'any'
462
            }
463
        }
391
    );
464
    );
392
465
393
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
466
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 399-408 subtest 'pickup_locations' => sub { Link Here
399
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
472
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_3_4) == 0, 'Any other combination renders no locations');
400
473
401
    #Case 12: holdallowed holdgroup, hold_fulfillment_policy holdingbranch
474
    #Case 12: holdallowed holdgroup, hold_fulfillment_policy holdingbranch
402
    $dbh->do(
475
    Koha::CirculationRules->set_rules(
403
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
476
        {
404
        {},
477
            branchcode => undef,
405
        3, 'holdingbranch'
478
            itemtype   => undef,
479
            categorycode => undef,
480
            rules => {
481
                holdallowed => 3,
482
                hold_fulfillment_policy => 'holdingbranch',
483
                returnbranch => 'any'
484
            }
485
        }
406
    );
486
    );
407
487
408
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
488
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 417-426 subtest 'pickup_locations' => sub { Link Here
417
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch');
497
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch');
418
498
419
    #Case 13: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'holdingbranch'
499
    #Case 13: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'holdingbranch'
420
    $dbh->do(
500
    Koha::CirculationRules->set_rules(
421
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
501
        {
422
        {},
502
            branchcode => undef,
423
        1, 'any'
503
            itemtype   => undef,
504
            categorycode => undef,
505
            rules => {
506
                holdallowed => 1,
507
                hold_fulfillment_policy => 'any',
508
                returnbranch => 'any'
509
            }
510
        }
424
    );
511
    );
425
512
426
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
513
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 432-441 subtest 'pickup_locations' => sub { Link Here
432
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any other combination renders no locations');
519
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any other combination renders no locations');
433
520
434
    #Case 14: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'holdingbranch'
521
    #Case 14: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'holdingbranch'
435
    $dbh->do(
522
    Koha::CirculationRules->set_rules(
436
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
523
        {
437
        {},
524
            branchcode => undef,
438
        1, 'holdgroup'
525
            itemtype   => undef,
526
            categorycode => undef,
527
            rules => {
528
                holdallowed => 1,
529
                hold_fulfillment_policy => 'holdgroup',
530
                returnbranch => 'any'
531
            }
532
        }
439
    );
533
    );
440
534
441
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
535
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 447-456 subtest 'pickup_locations' => sub { Link Here
447
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any other combination renders no locations');
541
    ok(scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any other combination renders no locations');
448
542
449
    #Case 15: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'holdingbranch'
543
    #Case 15: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'holdingbranch'
450
    $dbh->do(
544
    Koha::CirculationRules->set_rules(
451
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
545
        {
452
        {},
546
            branchcode => undef,
453
        1, 'homebranch'
547
            itemtype   => undef,
548
            categorycode => undef,
549
            rules => {
550
                holdallowed => 1,
551
                hold_fulfillment_policy => 'homebranch',
552
                returnbranch => 'any'
553
            }
554
        }
454
    );
555
    );
455
556
456
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
557
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
Lines 462-471 subtest 'pickup_locations' => sub { Link Here
462
    ok(scalar(@pl_3_4) == 0 && scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any combination of patron/item renders no locations');
563
    ok(scalar(@pl_3_4) == 0 && scalar(@pl_1_4) == 0 && scalar(@pl_3_1) == 0 && scalar(@pl_1_1) == 0, 'Any combination of patron/item renders no locations');
463
564
464
    #Case 16: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'holdingbranch'
565
    #Case 16: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'holdingbranch'
465
    $dbh->do(
566
    Koha::CirculationRules->set_rules(
466
        q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?},
567
        {
467
        {},
568
            branchcode => undef,
468
        1, 'holdingbranch'
569
            itemtype   => undef,
570
            categorycode => undef,
571
            rules => {
572
                holdallowed => 1,
573
                hold_fulfillment_policy => 'holdingbranch',
574
                returnbranch => 'any'
575
            }
576
        }
469
    );
577
    );
470
578
471
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
579
    @pl_1_1 = $item1->pickup_locations( { patron => $patron1 } );
(-)a/t/db_dependent/Koha/Libraries.t (-1 / +4 lines)
Lines 38-43 use t::lib::TestBuilder; Link Here
38
my $schema = Koha::Database->new->schema;
38
my $schema = Koha::Database->new->schema;
39
$schema->storage->txn_begin;
39
$schema->storage->txn_begin;
40
40
41
# Cleanup default_branch_item_rules
42
my $dbh     = C4::Context->dbh;
43
$dbh->do('DELETE FROM circulation_rules');
44
41
my $builder = t::lib::TestBuilder->new;
45
my $builder = t::lib::TestBuilder->new;
42
my $nb_of_libraries = Koha::Libraries->search->count;
46
my $nb_of_libraries = Koha::Libraries->search->count;
43
my $new_library_1 = Koha::Library->new({
47
my $new_library_1 = Koha::Library->new({
44
- 

Return to bug 22284