Lines 7-13
use t::lib::TestBuilder;
Link Here
|
7 |
|
7 |
|
8 |
use C4::Context; |
8 |
use C4::Context; |
9 |
|
9 |
|
10 |
use Test::More tests => 60; |
10 |
use Test::More tests => 61; |
11 |
use MARC::Record; |
11 |
use MARC::Record; |
12 |
|
12 |
|
13 |
use C4::Biblio; |
13 |
use C4::Biblio; |
Lines 244-256
is( $hold->priority, '6', "Test AlterPriority(), move to bottom" );
Link Here
|
244 |
my $foreign_biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' }); |
244 |
my $foreign_biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' }); |
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 |
$dbh->do('DELETE FROM issuingrules'); |
247 |
# Cleanup circulation rules |
248 |
$dbh->do( |
248 |
$dbh->do('DELETE FROM circulation_rules'); |
249 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) |
249 |
# $dbh->do( |
250 |
VALUES (?, ?, ?, ?, ?)}, |
250 |
# q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) |
251 |
{}, |
251 |
# VALUES (?, ?, ?, ?, ?)}, |
252 |
'*', '*', '*', 25, 99 |
252 |
# {}, |
253 |
); |
253 |
# '*', '*', '*', 25, 99 |
|
|
254 |
# ); |
254 |
$dbh->do( |
255 |
$dbh->do( |
255 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) |
256 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) |
256 |
VALUES (?, ?, ?, ?, ?)}, |
257 |
VALUES (?, ?, ?, ?, ?)}, |
Lines 565-570
subtest 'CanItemBeReserved / holds_per_day tests' => sub {
Link Here
|
565 |
|
566 |
|
566 |
Koha::Holds->search->delete; |
567 |
Koha::Holds->search->delete; |
567 |
$dbh->do('DELETE FROM issues'); |
568 |
$dbh->do('DELETE FROM issues'); |
|
|
569 |
$dbh->do('DELETE FROM issuingrules'); |
570 |
$dbh->do('DELETE FROM circulation_rules'); |
568 |
Koha::Items->search->delete; |
571 |
Koha::Items->search->delete; |
569 |
Koha::Biblios->search->delete; |
572 |
Koha::Biblios->search->delete; |
570 |
|
573 |
|
Lines 705-714
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
705 |
{}, |
708 |
{}, |
706 |
'*', '*', '*', 25 |
709 |
'*', '*', '*', 25 |
707 |
); |
710 |
); |
708 |
$dbh->do('DELETE FROM branch_item_rules'); |
711 |
$dbh->do('DELETE FROM circulation_rules'); |
709 |
$dbh->do('DELETE FROM default_branch_circ_rules'); |
|
|
710 |
$dbh->do('DELETE FROM default_branch_item_rules'); |
711 |
$dbh->do('DELETE FROM default_circ_rules'); |
712 |
|
712 |
|
713 |
Koha::Items->search->delete; |
713 |
Koha::Items->search->delete; |
714 |
Koha::Biblios->search->delete; |
714 |
Koha::Biblios->search->delete; |
Lines 762-772
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
762 |
); |
762 |
); |
763 |
|
763 |
|
764 |
# 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 |
765 |
$dbh->do( |
765 |
Koha::CirculationRules->set_rules( |
766 |
q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch) |
766 |
{ |
767 |
VALUES (?,?,?)}, |
767 |
branchcode => undef, |
768 |
{}, |
768 |
itemtype => undef, |
769 |
3, 'any', 'any' |
769 |
categorycode => undef, |
|
|
770 |
rules => { |
771 |
holdallowed => 3, |
772 |
hold_fulfillment_policy => 'any', |
773 |
returnbranch => 'any' |
774 |
} |
775 |
} |
770 |
); |
776 |
); |
771 |
|
777 |
|
772 |
# Test 2: Patron 1 can place hold |
778 |
# Test 2: Patron 1 can place hold |
Lines 784-797
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
784 |
); |
790 |
); |
785 |
|
791 |
|
786 |
# Cleanup default_cirt_rules |
792 |
# Cleanup default_cirt_rules |
787 |
$dbh->do('DELETE FROM default_circ_rules'); |
793 |
$dbh->do('DELETE FROM circulation_rules'); |
788 |
|
794 |
|
789 |
# Insert default circ rule to "any" for library 2 |
795 |
# Insert default circ rule to "any" for library 2 |
790 |
$dbh->do( |
796 |
Koha::CirculationRules->set_rules( |
791 |
q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
797 |
{ |
792 |
VALUES (?,?,?,?)}, |
798 |
branchcode => $library2->branchcode, |
793 |
{}, |
799 |
itemtype => undef, |
794 |
$library2->branchcode, 2, 'any', 'any' |
800 |
categorycode => undef, |
|
|
801 |
rules => { |
802 |
holdallowed => 2, |
803 |
hold_fulfillment_policy => 'any', |
804 |
returnbranch => 'any' |
805 |
} |
806 |
} |
795 |
); |
807 |
); |
796 |
|
808 |
|
797 |
# Test 4: Patron 3 can place hold |
809 |
# Test 4: Patron 3 can place hold |
Lines 802-812
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
802 |
); |
814 |
); |
803 |
|
815 |
|
804 |
# Update default circ rule to "hold group" for library 2 |
816 |
# Update default circ rule to "hold group" for library 2 |
805 |
$dbh->do( |
817 |
Koha::CirculationRules->set_rules( |
806 |
q{UPDATE default_branch_circ_rules set holdallowed = ? |
818 |
{ |
807 |
WHERE branchcode = ?}, |
819 |
branchcode => $library2->branchcode, |
808 |
{}, |
820 |
itemtype => undef, |
809 |
3, $library2->branchcode |
821 |
categorycode => undef, |
|
|
822 |
rules => { |
823 |
holdallowed => 3, |
824 |
hold_fulfillment_policy => 'any', |
825 |
returnbranch => 'any' |
826 |
} |
827 |
} |
810 |
); |
828 |
); |
811 |
|
829 |
|
812 |
# Test 5: Patron 3 cannot place hold |
830 |
# Test 5: Patron 3 cannot place hold |
Lines 817-830
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
817 |
); |
835 |
); |
818 |
|
836 |
|
819 |
# Cleanup default_branch_cirt_rules |
837 |
# Cleanup default_branch_cirt_rules |
820 |
$dbh->do('DELETE FROM default_branch_circ_rules'); |
838 |
$dbh->do('DELETE FROM circulation_rules'); |
821 |
|
839 |
|
822 |
# Insert default item rule to "any" for itemtype 2 |
840 |
# Insert default item rule to "any" for itemtype 2 |
823 |
$dbh->do( |
841 |
Koha::CirculationRules->set_rules( |
824 |
q{INSERT INTO default_branch_item_rules (itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
842 |
{ |
825 |
VALUES (?,?,?,?)}, |
843 |
branchcode => undef, |
826 |
{}, |
844 |
itemtype => $itemtype2->itemtype, |
827 |
$itemtype2->itemtype, 2, 'any', 'any' |
845 |
categorycode => undef, |
|
|
846 |
rules => { |
847 |
holdallowed => 2, |
848 |
hold_fulfillment_policy => 'any', |
849 |
returnbranch => 'any' |
850 |
} |
851 |
} |
828 |
); |
852 |
); |
829 |
|
853 |
|
830 |
# Test 6: Patron 3 can place hold |
854 |
# Test 6: Patron 3 can place hold |
Lines 835-845
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
835 |
); |
859 |
); |
836 |
|
860 |
|
837 |
# Update default item rule to "hold group" for itemtype 2 |
861 |
# Update default item rule to "hold group" for itemtype 2 |
838 |
$dbh->do( |
862 |
Koha::CirculationRules->set_rules( |
839 |
q{UPDATE default_branch_item_rules set holdallowed = ? |
863 |
{ |
840 |
WHERE itemtype = ?}, |
864 |
branchcode => undef, |
841 |
{}, |
865 |
itemtype => $itemtype2->itemtype, |
842 |
3, $itemtype2->itemtype |
866 |
categorycode => undef, |
|
|
867 |
rules => { |
868 |
holdallowed => 3, |
869 |
hold_fulfillment_policy => 'any', |
870 |
returnbranch => 'any' |
871 |
} |
872 |
} |
843 |
); |
873 |
); |
844 |
|
874 |
|
845 |
# Test 7: Patron 3 cannot place hold |
875 |
# Test 7: Patron 3 cannot place hold |
Lines 850-863
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
850 |
); |
880 |
); |
851 |
|
881 |
|
852 |
# Cleanup default_branch_item_rules |
882 |
# Cleanup default_branch_item_rules |
853 |
$dbh->do('DELETE FROM default_branch_item_rules'); |
883 |
$dbh->do('DELETE FROM circulation_rules'); |
854 |
|
884 |
|
855 |
# 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 |
856 |
$dbh->do( |
886 |
Koha::CirculationRules->set_rules( |
857 |
q{INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
887 |
{ |
858 |
VALUES (?,?,?,?,?)}, |
888 |
branchcode => $library2->branchcode, |
859 |
{}, |
889 |
itemtype => $itemtype2->itemtype, |
860 |
$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 |
} |
861 |
); |
897 |
); |
862 |
|
898 |
|
863 |
# Test 8: Patron 3 can place hold |
899 |
# Test 8: Patron 3 can place hold |
Lines 868-878
subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub {
Link Here
|
868 |
); |
904 |
); |
869 |
|
905 |
|
870 |
# 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 |
871 |
$dbh->do( |
907 |
Koha::CirculationRules->set_rules( |
872 |
q{UPDATE branch_item_rules set holdallowed = ? |
908 |
{ |
873 |
WHERE branchcode = ? and itemtype = ?}, |
909 |
branchcode => $library2->branchcode, |
874 |
{}, |
910 |
itemtype => $itemtype2->itemtype, |
875 |
3, $library2->branchcode, $itemtype2->itemtype |
911 |
categorycode => undef, |
|
|
912 |
rules => { |
913 |
holdallowed => 3, |
914 |
hold_fulfillment_policy => 'any', |
915 |
returnbranch => 'any' |
916 |
} |
917 |
} |
876 |
); |
918 |
); |
877 |
|
919 |
|
878 |
# Test 9: Patron 3 cannot place hold |
920 |
# Test 9: Patron 3 cannot place hold |
Lines 901-910
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
901 |
{}, |
943 |
{}, |
902 |
'*', '*', '*', 25 |
944 |
'*', '*', '*', 25 |
903 |
); |
945 |
); |
904 |
$dbh->do('DELETE FROM branch_item_rules'); |
946 |
$dbh->do('DELETE FROM circulation_rules'); |
905 |
$dbh->do('DELETE FROM default_branch_circ_rules'); |
|
|
906 |
$dbh->do('DELETE FROM default_branch_item_rules'); |
907 |
$dbh->do('DELETE FROM default_circ_rules'); |
908 |
|
947 |
|
909 |
Koha::Items->search->delete; |
948 |
Koha::Items->search->delete; |
910 |
Koha::Biblios->search->delete; |
949 |
Koha::Biblios->search->delete; |
Lines 958-968
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
958 |
); |
997 |
); |
959 |
|
998 |
|
960 |
# 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 |
961 |
$dbh->do( |
1000 |
Koha::CirculationRules->set_rules( |
962 |
q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch) |
1001 |
{ |
963 |
VALUES (?,?,?)}, |
1002 |
branchcode => undef, |
964 |
{}, |
1003 |
itemtype => undef, |
965 |
2, 'holdgroup', 'any' |
1004 |
categorycode => undef, |
|
|
1005 |
rules => { |
1006 |
holdallowed => 2, |
1007 |
hold_fulfillment_policy => 'holdgroup', |
1008 |
returnbranch => 'any' |
1009 |
} |
1010 |
} |
966 |
); |
1011 |
); |
967 |
|
1012 |
|
968 |
# Test 2: Patron 1 can place hold |
1013 |
# Test 2: Patron 1 can place hold |
Lines 980-993
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
980 |
); |
1025 |
); |
981 |
|
1026 |
|
982 |
# Cleanup default_cirt_rules |
1027 |
# Cleanup default_cirt_rules |
983 |
$dbh->do('DELETE FROM default_circ_rules'); |
1028 |
$dbh->do('DELETE FROM circulation_rules'); |
984 |
|
1029 |
|
985 |
# Insert default circ rule to "any" for library 2 |
1030 |
# Insert default circ rule to "any" for library 2 |
986 |
$dbh->do( |
1031 |
Koha::CirculationRules->set_rules( |
987 |
q{INSERT INTO default_branch_circ_rules (branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
1032 |
{ |
988 |
VALUES (?,?,?,?)}, |
1033 |
branchcode => $library2->branchcode, |
989 |
{}, |
1034 |
itemtype => undef, |
990 |
$library2->branchcode, 2, 'any', 'any' |
1035 |
categorycode => undef, |
|
|
1036 |
rules => { |
1037 |
holdallowed => 2, |
1038 |
hold_fulfillment_policy => 'any', |
1039 |
returnbranch => 'any' |
1040 |
} |
1041 |
} |
991 |
); |
1042 |
); |
992 |
|
1043 |
|
993 |
# Test 4: Patron 3 can place hold |
1044 |
# Test 4: Patron 3 can place hold |
Lines 998-1008
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
998 |
); |
1049 |
); |
999 |
|
1050 |
|
1000 |
# Update default circ rule to "hold group" for library 2 |
1051 |
# Update default circ rule to "hold group" for library 2 |
1001 |
$dbh->do( |
1052 |
Koha::CirculationRules->set_rules( |
1002 |
q{UPDATE default_branch_circ_rules set hold_fulfillment_policy = ? |
1053 |
{ |
1003 |
WHERE branchcode = ?}, |
1054 |
branchcode => $library2->branchcode, |
1004 |
{}, |
1055 |
itemtype => undef, |
1005 |
'holdgroup', $library2->branchcode |
1056 |
categorycode => undef, |
|
|
1057 |
rules => { |
1058 |
holdallowed => 2, |
1059 |
hold_fulfillment_policy => 'holdgroup', |
1060 |
returnbranch => 'any' |
1061 |
} |
1062 |
} |
1006 |
); |
1063 |
); |
1007 |
|
1064 |
|
1008 |
# Test 5: Patron 3 cannot place hold |
1065 |
# Test 5: Patron 3 cannot place hold |
Lines 1013-1026
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
1013 |
); |
1070 |
); |
1014 |
|
1071 |
|
1015 |
# Cleanup default_branch_cirt_rules |
1072 |
# Cleanup default_branch_cirt_rules |
1016 |
$dbh->do('DELETE FROM default_branch_circ_rules'); |
1073 |
$dbh->do('DELETE FROM circulation_rules'); |
1017 |
|
1074 |
|
1018 |
# Insert default item rule to "any" for itemtype 2 |
1075 |
# Insert default item rule to "any" for itemtype 2 |
1019 |
$dbh->do( |
1076 |
Koha::CirculationRules->set_rules( |
1020 |
q{INSERT INTO default_branch_item_rules (itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
1077 |
{ |
1021 |
VALUES (?,?,?,?)}, |
1078 |
branchcode => undef, |
1022 |
{}, |
1079 |
itemtype => $itemtype2->itemtype, |
1023 |
$itemtype2->itemtype, 2, 'any', 'any' |
1080 |
categorycode => undef, |
|
|
1081 |
rules => { |
1082 |
holdallowed => 2, |
1083 |
hold_fulfillment_policy => 'any', |
1084 |
returnbranch => 'any' |
1085 |
} |
1086 |
} |
1024 |
); |
1087 |
); |
1025 |
|
1088 |
|
1026 |
# Test 6: Patron 3 can place hold |
1089 |
# Test 6: Patron 3 can place hold |
Lines 1031-1041
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
1031 |
); |
1094 |
); |
1032 |
|
1095 |
|
1033 |
# Update default item rule to "hold group" for itemtype 2 |
1096 |
# Update default item rule to "hold group" for itemtype 2 |
1034 |
$dbh->do( |
1097 |
Koha::CirculationRules->set_rules( |
1035 |
q{UPDATE default_branch_item_rules set hold_fulfillment_policy = ? |
1098 |
{ |
1036 |
WHERE itemtype = ?}, |
1099 |
branchcode => undef, |
1037 |
{}, |
1100 |
itemtype => $itemtype2->itemtype, |
1038 |
'holdgroup', $itemtype2->itemtype |
1101 |
categorycode => undef, |
|
|
1102 |
rules => { |
1103 |
holdallowed => 2, |
1104 |
hold_fulfillment_policy => 'holdgroup', |
1105 |
returnbranch => 'any' |
1106 |
} |
1107 |
} |
1039 |
); |
1108 |
); |
1040 |
|
1109 |
|
1041 |
# Test 7: Patron 3 cannot place hold |
1110 |
# Test 7: Patron 3 cannot place hold |
Lines 1046-1059
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
1046 |
); |
1115 |
); |
1047 |
|
1116 |
|
1048 |
# Cleanup default_branch_item_rules |
1117 |
# Cleanup default_branch_item_rules |
1049 |
$dbh->do('DELETE FROM default_branch_item_rules'); |
1118 |
$dbh->do('DELETE FROM circulation_rules'); |
1050 |
|
1119 |
|
1051 |
# 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 |
1052 |
$dbh->do( |
1121 |
Koha::CirculationRules->set_rules( |
1053 |
q{INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
1122 |
{ |
1054 |
VALUES (?,?,?,?,?)}, |
1123 |
branchcode => $library2->branchcode, |
1055 |
{}, |
1124 |
itemtype => $itemtype2->itemtype, |
1056 |
$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 |
} |
1057 |
); |
1132 |
); |
1058 |
|
1133 |
|
1059 |
# Test 8: Patron 3 can place hold |
1134 |
# Test 8: Patron 3 can place hold |
Lines 1064-1074
subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub {
Link Here
|
1064 |
); |
1139 |
); |
1065 |
|
1140 |
|
1066 |
# 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 |
1067 |
$dbh->do( |
1142 |
Koha::CirculationRules->set_rules( |
1068 |
q{UPDATE branch_item_rules set hold_fulfillment_policy = ? |
1143 |
{ |
1069 |
WHERE branchcode = ? and itemtype = ?}, |
1144 |
branchcode => $library2->branchcode, |
1070 |
{}, |
1145 |
itemtype => $itemtype2->itemtype, |
1071 |
'holdgroup', $library2->branchcode, $itemtype2->itemtype |
1146 |
categorycode => undef, |
|
|
1147 |
rules => { |
1148 |
holdallowed => 2, |
1149 |
hold_fulfillment_policy => 'holdgroup', |
1150 |
returnbranch => 'any' |
1151 |
} |
1152 |
} |
1072 |
); |
1153 |
); |
1073 |
|
1154 |
|
1074 |
# Test 9: Patron 3 cannot place hold |
1155 |
# Test 9: Patron 3 cannot place hold |