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-809
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 |
808 |
is_deeply( |
810 |
is_deeply( |
809 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
811 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
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-875
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 |
874 |
is_deeply( |
900 |
is_deeply( |
875 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
901 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
Lines 878-890
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 |
889 |
is_deeply( |
921 |
is_deeply( |
890 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
922 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2 ), |
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-1020
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 |
1019 |
is_deeply( |
1066 |
is_deeply( |
1020 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2, $library3->branchcode ), |
1067 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2, $library3->branchcode ), |
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-1053
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 |
1052 |
is_deeply( |
1111 |
is_deeply( |
1053 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2, $library3->branchcode ), |
1112 |
CanItemBeReserved( $patron3->borrowernumber, $itemnumber_2, $library3->branchcode ), |
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 |