|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
|
25 |
|
|
Lines 34-39
use t::lib::TestBuilder;
Link Here
|
| 34 |
my $schema = Koha::Database->new->schema; |
34 |
my $schema = Koha::Database->new->schema; |
| 35 |
my $builder = t::lib::TestBuilder->new; |
35 |
my $builder = t::lib::TestBuilder->new; |
| 36 |
|
36 |
|
|
|
37 |
subtest 'new' => sub { |
| 38 |
|
| 39 |
plan tests => 2; |
| 40 |
|
| 41 |
$schema->storage->txn_begin; |
| 42 |
|
| 43 |
throws_ok { Koha::Account->new(); } qr/No patron id passed in!/, 'Croaked on bad call to new'; |
| 44 |
|
| 45 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 46 |
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); |
| 47 |
is( defined $account, 1, "Account is defined" ); |
| 48 |
|
| 49 |
$schema->storage->txn_rollback; |
| 50 |
}; |
| 51 |
|
| 37 |
subtest 'outstanding_debits() tests' => sub { |
52 |
subtest 'outstanding_debits() tests' => sub { |
| 38 |
|
53 |
|
| 39 |
plan tests => 22; |
54 |
plan tests => 22; |
|
Lines 141-147
subtest 'outstanding_credits() tests' => sub {
Link Here
|
| 141 |
|
156 |
|
| 142 |
subtest 'add_credit() tests' => sub { |
157 |
subtest 'add_credit() tests' => sub { |
| 143 |
|
158 |
|
| 144 |
plan tests => 16; |
159 |
plan tests => 15; |
| 145 |
|
160 |
|
| 146 |
$schema->storage->txn_begin; |
161 |
$schema->storage->txn_begin; |
| 147 |
|
162 |
|
|
Lines 151-157
subtest 'add_credit() tests' => sub {
Link Here
|
| 151 |
|
166 |
|
| 152 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
167 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 153 |
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); |
168 |
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); |
| 154 |
is( defined $account, 1, "Account is defined" ); |
|
|
| 155 |
|
169 |
|
| 156 |
is( $account->balance, 0, 'Patron has no balance' ); |
170 |
is( $account->balance, 0, 'Patron has no balance' ); |
| 157 |
|
171 |
|
| 158 |
- |
|
|