1 package KohaTest::Overdues::GetBranchcodesWithOverdueRules;
2 use base qw( KohaTest::Overdues );
10 sub my_branch_has_no_rules : Tests( 2 ) {
13 ok( $self->{'branchcode'}, "we're looking for branch $self->{'branchcode'}" );
15 my @branches = C4::Overdues::GetBranchcodesWithOverdueRules;
16 my @found_branches = grep { $_ eq $self->{'branchcode'} } @branches;
17 is( scalar @found_branches, 0, '...and it is not in the list of branches')
21 sub my_branch_has_overdue_rules : Tests( 3 ) {
24 ok( $self->{'branchcode'}, "we're looking for branch $self->{'branchcode'}" );
26 my $dbh = C4::Context->dbh();
27 my $sql = <<'END_SQL';
28 INSERT INTO overduerules
29 (branchcode, categorycode,
30 delay1, letter1, debarred1,
31 delay2, letter2, debarred2,
32 delay3, letter3, debarred3)
40 my $sth = $dbh->prepare($sql);
41 my $success = $sth->execute( $self->{'branchcode'}, $self->random_string(2),
42 1, $self->random_string(), 0,
43 5, $self->random_string(), 0,
44 9, $self->random_string(), 1, );
45 ok( $success, '...and we have successfully given it an overdue rule' );
47 my @branches = C4::Overdues::GetBranchcodesWithOverdueRules;
48 my @found_branches = grep { $_ eq $self->{'branchcode'} } @branches;
49 is( scalar @found_branches, 1, '...and it IS in the list of branches.')