Lines 1-11
Link Here
|
1 |
#!/usr/bin/perl; |
1 |
#!/usr/bin/perl; |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
use Test::More;# tests => 3; |
4 |
use Test::More tests => 16; |
5 |
|
5 |
|
6 |
use C4::Context; |
6 |
use C4::Context; |
|
|
7 |
use C4::Branch; |
7 |
use_ok('C4::Overdues'); |
8 |
use_ok('C4::Overdues'); |
8 |
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes'); |
9 |
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes'); |
|
|
10 |
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules'); |
9 |
|
11 |
|
10 |
my $dbh = C4::Context->dbh; |
12 |
my $dbh = C4::Context->dbh; |
11 |
$dbh->{AutoCommit} = 0; |
13 |
$dbh->{AutoCommit} = 0; |
Lines 73-77
is_deeply( $mtts, ['email', 'sms'], 'GetOverdueMessageTransportTypes: second ove
Link Here
|
73 |
$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 3); |
75 |
$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 3); |
74 |
is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' ); |
76 |
is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' ); |
75 |
|
77 |
|
|
|
78 |
# Test GetBranchcodesWithOverdueRules |
79 |
$dbh->do(q|DELETE FROM overduerules|); |
80 |
$dbh->do(q| |
81 |
INSERT INTO overduerules |
82 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
83 |
VALUES |
84 |
( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
85 |
|); |
86 |
|
87 |
my $all_branches = C4::Branch::GetBranches; |
88 |
my @branchcodes = keys %$all_branches; |
89 |
|
90 |
my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
91 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' ); |
92 |
|
93 |
$dbh->do(q| |
94 |
INSERT INTO overduerules |
95 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
96 |
VALUES |
97 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
98 |
|); |
99 |
|
100 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
101 |
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists and a specific rule exists, all branches should be returned' ); |
102 |
|
103 |
$dbh->do(q|DELETE FROM overduerules|); |
104 |
$dbh->do(q| |
105 |
INSERT INTO overduerules |
106 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
107 |
VALUES |
108 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
109 |
|); |
110 |
|
111 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
112 |
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' ); |
113 |
|
114 |
$dbh->do(q|DELETE FROM overduerules|); |
115 |
$dbh->do(q| |
116 |
INSERT INTO overduerules |
117 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
118 |
VALUES |
119 |
( 'CPL', '', 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ), |
120 |
( 'MPL', '', 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 ) |
121 |
|); |
76 |
|
122 |
|
77 |
done_testing; |
123 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); |
|
|
124 |
is_deeply( \@overdue_branches, ['CPL', 'MPL'] , 'If only 2 specific rules exist, 2 branches should be returned' ); |
78 |
- |
|
|