|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 40; |
22 |
use Test::More tests => 41; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
|
Lines 1977-1980
subtest 'anonymize' => sub {
Link Here
|
| 1977 |
$patron2->discard_changes; # refresh |
1977 |
$patron2->discard_changes; # refresh |
| 1978 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1978 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
| 1979 |
}; |
1979 |
}; |
|
|
1980 |
|
| 1980 |
$schema->storage->txn_rollback; |
1981 |
$schema->storage->txn_rollback; |
| 1981 |
- |
1982 |
|
|
|
1983 |
subtest 'search_patrons_with_unpaid_fines() tests' => sub { |
| 1984 |
|
| 1985 |
plan tests => 7; |
| 1986 |
|
| 1987 |
$schema->storage->txn_begin; |
| 1988 |
|
| 1989 |
my $patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
| 1990 |
is( scalar( @$patrons_with_fines ), 0, 'search_patrons_with_unpaid_fines() should return empty array' ); |
| 1991 |
|
| 1992 |
my $library = $builder->build({source => 'Branch' }); |
| 1993 |
|
| 1994 |
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
| 1995 |
my $account1 = $patron1->account; |
| 1996 |
$account1->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
| 1997 |
|
| 1998 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
| 1999 |
my $account2 = $patron2->account; |
| 2000 |
$account2->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
| 2001 |
|
| 2002 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
| 2003 |
is( scalar( @$patrons_with_fines ), 2, 'search_patrons_with_unpaid_fines() should return array with 2 values' ); |
| 2004 |
is( $patrons_with_fines->[0]->{ borrowernumber }, $patron1->borrowernumber, 'patron1 should be in array'); |
| 2005 |
is( $patrons_with_fines->[1]->{ borrowernumber }, $patron2->borrowernumber, 'patron2 should be in array'); |
| 2006 |
is( $patrons_with_fines->[0]->{ accountbalance }, $account1->balance, 'patron1 fines are correct'); |
| 2007 |
is( $patrons_with_fines->[1]->{ accountbalance }, $account2->balance, 'patron2 fines are correct'); |
| 2008 |
|
| 2009 |
$account2->add_credit({ amount => 10, interface => 'commandline' }); |
| 2010 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
| 2011 |
is( scalar( @$patrons_with_fines ), 1, 'Patron without fines is not in array'); |
| 2012 |
|
| 2013 |
$schema->storage->txn_rollback; |
| 2014 |
}; |