Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
|
23 |
|
24 |
use Koha::Account; |
24 |
use Koha::Account; |
25 |
use Koha::Account::Lines; |
25 |
use Koha::Account::Lines; |
Lines 60-65
subtest 'outstanding_debits() tests' => sub {
Link Here
|
60 |
$schema->storage->txn_rollback; |
60 |
$schema->storage->txn_rollback; |
61 |
}; |
61 |
}; |
62 |
|
62 |
|
|
|
63 |
subtest 'outstanding_credits() tests' => sub { |
64 |
|
65 |
plan tests => 5; |
66 |
|
67 |
$schema->storage->txn_begin; |
68 |
|
69 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
70 |
my $account = Koha::Account->new({ patron_id => $patron->id }); |
71 |
|
72 |
my @generated_lines; |
73 |
push @generated_lines, $account->add_credit({ amount => 1 }); |
74 |
push @generated_lines, $account->add_credit({ amount => 2 }); |
75 |
push @generated_lines, $account->add_credit({ amount => 3 }); |
76 |
push @generated_lines, $account->add_credit({ amount => 4 }); |
77 |
|
78 |
my ( $total, $lines ) = $account->outstanding_credits(); |
79 |
|
80 |
is( $total, -10, 'Outstandig debits total is correctly calculated' ); |
81 |
|
82 |
my $i = 0; |
83 |
foreach my $line ( @{ $lines->as_list } ) { |
84 |
my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); |
85 |
is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); |
86 |
$i++; |
87 |
} |
88 |
|
89 |
$schema->storage->txn_rollback; |
90 |
}; |
91 |
|
63 |
subtest 'add_credit() tests' => sub { |
92 |
subtest 'add_credit() tests' => sub { |
64 |
|
93 |
|
65 |
plan tests => 15; |
94 |
plan tests => 15; |
66 |
- |
|
|