Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 42; |
22 |
use Test::More tests => 43; |
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 2184-2187
subtest 'queue_notice' => sub {
Link Here
|
2184 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2184 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2185 |
}; |
2185 |
}; |
2186 |
|
2186 |
|
2187 |
$schema->storage->txn_rollback; |
2187 |
subtest 'filter_by_owings' => sub { |
|
|
2188 |
|
2189 |
plan tests => 7; |
2190 |
|
2191 |
my $library = $builder->build({source => 'Branch' }); |
2192 |
my $max_owing = 10; |
2193 |
|
2194 |
my $patrons = Koha::Patrons->filter_by_owings({ branchcode => $library->{branchcode}, amountoutstanding => { '>=' => $max_owing } }); |
2195 |
is(ref($patrons), 'Koha::Patrons', 'filter_by_owings returns set of Koha::Patrons'); |
2196 |
is($patrons->count, 0, 'Empty set of Koha::Patrons returned'); |
2197 |
|
2198 |
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2199 |
my $account1 = $patron1->account; |
2200 |
$account1->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE', library_id => $library->{branchcode} }); |
2201 |
|
2202 |
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->{branchcode} }}); |
2203 |
my $account2 = $patron2->account; |
2204 |
$account2->add_debit({ amount => 10, interface => 'commandline', type => 'OVERDUE', library_id => $library->{branchcode} }); |
2205 |
|
2206 |
t::lib::Mocks::mock_userenv({ patron => $patron1 }); |
2207 |
|
2208 |
$patrons = Koha::Patrons->filter_by_owings({ branchcode => $library->{branchcode}, amountoutstanding => { '>=' => $max_owing } }); |
2209 |
is($patrons->count, 2, 'filter_by_debts() should return set of 2 patrons when filtered with amountoutstanding'); |
2210 |
|
2211 |
my $found_patron1 = $patrons->find($patron1->borrowernumber); |
2212 |
my $found_patron2 = $patrons->find($patron2->borrowernumber); |
2213 |
|
2214 |
is($found_patron1->borrowernumber, $patron1->borrowernumber, 'patron 1 returned'); |
2215 |
is($found_patron2->borrowernumber, $patron2->borrowernumber, 'patron 2 returned'); |
2216 |
|
2217 |
$account1->pay({ amount => 10, interface => 'commandline', library_id => $library->{branchcode}, manager_id => $patron1->borrowernumber }); |
2218 |
$patrons = Koha::Patrons->filter_by_owings({ branchcode => $library->{branchcode}, amountoutstanding => { '>=' => $max_owing } }); |
2219 |
|
2220 |
is( $patrons->count, 1, 'filter_by_debts() should return 1 patron when filtered with amountoutstanding'); |
2221 |
my $found_patron = $patrons->next; |
2222 |
is( $found_patron->borrowernumber, $patron2->borrowernumber, 'Only patron 2 returned'); |
2223 |
|
2224 |
}; |
2225 |
|
2226 |
$schema->storage->txn_rollback; |
2188 |
- |
|
|