Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 41; |
22 |
use Test::More tests => 42; |
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 2030-2035
subtest 'anonymize' => sub {
Link Here
|
2030 |
$patron2->discard_changes; # refresh |
2030 |
$patron2->discard_changes; # refresh |
2031 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
2031 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
2032 |
}; |
2032 |
}; |
|
|
2033 |
|
2033 |
$schema->storage->txn_rollback; |
2034 |
$schema->storage->txn_rollback; |
2034 |
|
2035 |
|
2035 |
subtest 'extended_attributes' => sub { |
2036 |
subtest 'extended_attributes' => sub { |
Lines 2204-2206
subtest 'extended_attributes' => sub {
Link Here
|
2204 |
|
2205 |
|
2205 |
$schema->storage->txn_rollback; |
2206 |
$schema->storage->txn_rollback; |
2206 |
}; |
2207 |
}; |
2207 |
- |
2208 |
|
|
|
2209 |
subtest 'search_patrons_with_unpaid_fines() tests' => sub { |
2210 |
|
2211 |
plan tests => 7; |
2212 |
|
2213 |
$schema->storage->txn_begin; |
2214 |
|
2215 |
my $patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2216 |
is( scalar( @$patrons_with_fines ), 0, 'search_patrons_with_unpaid_fines() should return empty array' ); |
2217 |
|
2218 |
my $library = $builder->build({source => 'Branch' }); |
2219 |
|
2220 |
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2221 |
my $account1 = $patron1->account; |
2222 |
$account1->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
2223 |
|
2224 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2225 |
my $account2 = $patron2->account; |
2226 |
$account2->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
2227 |
|
2228 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2229 |
is( scalar( @$patrons_with_fines ), 2, 'search_patrons_with_unpaid_fines() should return array with 2 values' ); |
2230 |
is( $patrons_with_fines->[0]->{ borrowernumber }, $patron1->borrowernumber, 'patron1 should be in array'); |
2231 |
is( $patrons_with_fines->[1]->{ borrowernumber }, $patron2->borrowernumber, 'patron2 should be in array'); |
2232 |
is( $patrons_with_fines->[0]->{ accountbalance }, $account1->balance, 'patron1 fines are correct'); |
2233 |
is( $patrons_with_fines->[1]->{ accountbalance }, $account2->balance, 'patron2 fines are correct'); |
2234 |
|
2235 |
$account2->add_credit({ amount => 10, interface => 'commandline' }); |
2236 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2237 |
is( scalar( @$patrons_with_fines ), 1, 'Patron without fines is not in array'); |
2238 |
|
2239 |
$schema->storage->txn_rollback; |
2240 |
} |