|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
use Modern::Perl; |
| 4 |
use Test::More tests => 3; |
| 5 |
|
| 6 |
use C4::Branch; |
| 7 |
use C4::Context; |
| 8 |
use C4::Overdues; |
| 9 |
|
| 10 |
my $dbh = C4::Context->dbh; |
| 11 |
$dbh->{AutoCommit} = 0; |
| 12 |
$dbh->{RaiseError} = 1; |
| 13 |
|
| 14 |
$dbh->do(q|DELETE FROM overduerules|); |
| 15 |
$dbh->do(q| |
| 16 |
INSERT INTO overduerules |
| 17 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
| 18 |
VALUES |
| 19 |
( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
| 20 |
|); |
| 21 |
|
| 22 |
my $all_branches = C4::Branch::GetBranches; |
| 23 |
my @branchcodes = keys %$all_branches; |
| 24 |
|
| 25 |
my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; |
| 26 |
is_deeply( \@overdue_branches, \@branchcodes, 'If a default rule exists, all branches should be returned' ); |
| 27 |
|
| 28 |
$dbh->do(q| |
| 29 |
INSERT INTO overduerules |
| 30 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
| 31 |
VALUES |
| 32 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
| 33 |
|); |
| 34 |
|
| 35 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; |
| 36 |
is_deeply( \@overdue_branches, \@branchcodes, 'If a default rule exists and a specific rule exists, all branches should be returned' ); |
| 37 |
|
| 38 |
$dbh->do(q|DELETE FROM overduerules|); |
| 39 |
$dbh->do(q| |
| 40 |
INSERT INTO overduerules |
| 41 |
( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) |
| 42 |
VALUES |
| 43 |
( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |
| 44 |
|); |
| 45 |
|
| 46 |
@overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules; |
| 47 |
is_deeply( \@overdue_branches, ['CPL'] , 'If only a specific rule exist, only 1 branch should be returned' ); |