Lines 83-135
$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 3);
Link Here
|
83 |
is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' ); |
83 |
is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' ); |
84 |
|
84 |
|
85 |
# Test GetBranchcodesWithOverdueRules |
85 |
# Test GetBranchcodesWithOverdueRules |
86 |
$dbh->do(q|DELETE FROM overduerules|); |
86 |
$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); |
87 |
|
87 |
|
88 |
my @overdue_branches; |
88 |
my @overdue_branches; |
89 |
warnings_are { @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); } [], |
89 |
warnings_are { @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); } [], |
90 |
"No warnings thrown when no overdue rules exist"; |
90 |
"No warnings thrown when no overdue rules exist"; |
91 |
|
91 |
|
92 |
$dbh->do(q| |
92 |
$dbh->do( |
93 |
INSERT INTO overduerules |
93 |
q| |
94 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
94 |
INSERT INTO circulation_rules |
|
|
95 |
( branchcode, categorycode, itemtype, rule_name, rule_value ) |
95 |
VALUES |
96 |
VALUES |
96 |
( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
97 |
( NULL, NULL, NULL, 'overdue_1_delay', 1 ) |
97 |
|); |
98 |
| |
|
|
99 |
); |
98 |
|
100 |
|
99 |
my @branchcodes = map { $_->branchcode } Koha::Libraries->search->as_list; |
101 |
my @branchcodes = map { $_->branchcode } Koha::Libraries->search->as_list; |
100 |
|
102 |
|
101 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
103 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
102 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' ); |
104 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' ); |
103 |
|
105 |
|
104 |
$dbh->do(q| |
106 |
$dbh->do( |
105 |
INSERT INTO overduerules |
107 |
q| |
106 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
108 |
INSERT INTO circulation_rules |
|
|
109 |
( branchcode, categorycode, itemtype, rule_name, rule_value ) |
107 |
VALUES |
110 |
VALUES |
108 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
111 |
( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ) |
109 |
|); |
112 |
| |
|
|
113 |
); |
110 |
|
114 |
|
111 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
115 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
112 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists and a specific rule exists, all branches should be returned' ); |
116 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists and a specific rule exists, all branches should be returned' ); |
113 |
|
117 |
|
114 |
$dbh->do(q|DELETE FROM overduerules|); |
118 |
$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); |
115 |
$dbh->do(q| |
119 |
$dbh->do(q| |
116 |
INSERT INTO overduerules |
120 |
INSERT INTO circulation_rules |
117 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
121 |
( branchcode, categorycode, itemtype, rule_name, rule_value ) |
118 |
VALUES |
122 |
VALUES |
119 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
123 |
( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ) |
120 |
|); |
124 |
|); |
121 |
|
125 |
|
122 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
126 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
123 |
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' ); |
127 |
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' ); |
124 |
|
128 |
|
125 |
$dbh->do(q|DELETE FROM overduerules|); |
129 |
$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); |
126 |
$dbh->do(q| |
130 |
$dbh->do( |
127 |
INSERT INTO overduerules |
131 |
q| |
128 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
132 |
INSERT INTO circulation_rules |
|
|
133 |
( branchcode, categorycode, itemtype, rule_name, rule_value ) |
129 |
VALUES |
134 |
VALUES |
130 |
( 'CPL', '', 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ), |
135 |
( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ), |
131 |
( 'MPL', '', 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 ) |
136 |
( 'MPL', NULL, NULL, 'overdue_1_delay', 1 ) |
132 |
|); |
137 |
| |
|
|
138 |
); |
133 |
|
139 |
|
134 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
140 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
135 |
is_deeply( \@overdue_branches, ['CPL', 'MPL'] , 'If only 2 specific rules exist, 2 branches should be returned' ); |
141 |
is_deeply( \@overdue_branches, ['CPL', 'MPL'] , 'If only 2 specific rules exist, 2 branches should be returned' ); |
136 |
- |
|
|