Koha/t/lib/KohaTest/Overdues/GetBranchcodesWithOverdueRules.pm
Andrew Moore 8ae66932cd Bug 2274 [3/5]: consolidating overdue notice cronjobs into one
This patch adds the misc/cronjobs/overdue_notices.pl script that is intended to replace
overduenotices.pl, overduenotices-30.pl and overduenotices-csv.pl. It adds messages to
the message_queue to be sent later (by process_message_queue.pl). It also marks borrowers
as debarred if their issues become too overdue.

It is intended to be run from cron nightly with usage something like:
0 2 * * * misc/cronjobs/overdue_notices.pl

C4::Members:
 - improved documentation on ModMember
 - made ModMember return a useful value (the return value of the database call)
 - added a DebarMember method
 - adding t/lib/KohaTest/Members/DebarMember.pm to test ModMember

misc/cronjobs/overdue_notices.pl
 - designed to replace overduenotices.pl, overduenotices-30.pl, and overduenotice-csv

Changes to C4::Letters:
 - EnqueueLetter now lets you pass in to_address and from_address which can override defaults
 - _send_message_by_email pays attention to these defaults.
 - now handles attachments with MIME::Lite

C4::Overdues
 - added GetBranchcodesWithOverdueRules
   - added t/lib/KohaTest/Overdues/GerBranchcodesWithOverdueRules.pm to test that.

circ/overdue.pl
 - replaced call to obsolete overduenotices-csv.pl with call to overdue_notices.pl

KohaTest:
 - added three helper methods: random_phone, random_email, random_ip
   - these can be used to populate example records
 - you can now pass an optional lengh to random_string

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-07-10 09:10:46 -05:00

59 lines
1.6 KiB
Perl

package KohaTest::Overdues::GetBranchcodesWithOverdueRules;
use base qw( KohaTest::Overdues );
use strict;
use warnings;
use C4::Overdues;
use Test::More;
sub my_branch_has_no_rules : Tests( 2 ) {
my $self = shift;
ok( $self->{'branchcode'}, "we're looking for branch $self->{'branchcode'}" );
my @branches = C4::Overdues::GetBranchcodesWithOverdueRules;
my @found_branches = grep { $_ eq $self->{'branchcode'} } @branches;
is( scalar @found_branches, 0, '...and it is not in the list of branches')
}
sub my_branch_has_overdue_rules : Tests( 3 ) {
my $self = shift;
ok( $self->{'branchcode'}, "we're looking for branch $self->{'branchcode'}" );
my $dbh = C4::Context->dbh();
my $sql = <<'END_SQL';
INSERT INTO overduerules
(branchcode, categorycode,
delay1, letter1, debarred1,
delay2, letter2, debarred2,
delay3, letter3, debarred3)
VALUES
( ?, ?,
?, ?, ?,
?, ?, ?,
?, ?, ?)
END_SQL
my $sth = $dbh->prepare($sql);
my $success = $sth->execute( $self->{'branchcode'}, $self->random_string(2),
1, $self->random_string(), 0,
5, $self->random_string(), 0,
9, $self->random_string(), 1, );
ok( $success, '...and we have successfully given it an overdue rule' );
my @branches = C4::Overdues::GetBranchcodesWithOverdueRules;
my @found_branches = grep { $_ eq $self->{'branchcode'} } @branches;
is( scalar @found_branches, 1, '...and it IS in the list of branches.')
}
1;