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 1947-1952
subtest 'anonymize' => sub {
Link Here
|
1947 |
$patron2->discard_changes; # refresh |
1947 |
$patron2->discard_changes; # refresh |
1948 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1948 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1949 |
}; |
1949 |
}; |
|
|
1950 |
|
1950 |
$schema->storage->txn_rollback; |
1951 |
$schema->storage->txn_rollback; |
1951 |
|
1952 |
|
1952 |
subtest 'extended_attributes' => sub { |
1953 |
subtest 'extended_attributes' => sub { |
Lines 2121-2123
subtest 'extended_attributes' => sub {
Link Here
|
2121 |
|
2122 |
|
2122 |
$schema->storage->txn_rollback; |
2123 |
$schema->storage->txn_rollback; |
2123 |
}; |
2124 |
}; |
2124 |
- |
2125 |
|
|
|
2126 |
subtest 'search_patrons_with_unpaid_fines() tests' => sub { |
2127 |
|
2128 |
plan tests => 7; |
2129 |
|
2130 |
$schema->storage->txn_begin; |
2131 |
|
2132 |
my $patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2133 |
is( scalar( @$patrons_with_fines ), 0, 'search_patrons_with_unpaid_fines() should return empty array' ); |
2134 |
|
2135 |
my $library = $builder->build({source => 'Branch' }); |
2136 |
|
2137 |
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2138 |
my $account1 = $patron1->account; |
2139 |
$account1->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
2140 |
|
2141 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2142 |
my $account2 = $patron2->account; |
2143 |
$account2->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE' }); |
2144 |
|
2145 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2146 |
is( scalar( @$patrons_with_fines ), 2, 'search_patrons_with_unpaid_fines() should return array with 2 values' ); |
2147 |
is( $patrons_with_fines->[0]->{ borrowernumber }, $patron1->borrowernumber, 'patron1 should be in array'); |
2148 |
is( $patrons_with_fines->[1]->{ borrowernumber }, $patron2->borrowernumber, 'patron2 should be in array'); |
2149 |
is( $patrons_with_fines->[0]->{ accountbalance }, $account1->balance, 'patron1 fines are correct'); |
2150 |
is( $patrons_with_fines->[1]->{ accountbalance }, $account2->balance, 'patron2 fines are correct'); |
2151 |
|
2152 |
$account2->add_credit({ amount => 10, interface => 'commandline' }); |
2153 |
$patrons_with_fines = Koha::Patrons->search({ branchcode => $library->{branchcode} })->search_patrons_with_unpaid_fines(); |
2154 |
is( scalar( @$patrons_with_fines ), 1, 'Patron without fines is not in array'); |
2155 |
|
2156 |
$schema->storage->txn_rollback; |
2157 |
} |