From d4a15fc1f141aa7ddf5ccd487eb9ae3df8048005 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Dec 2016 07:58:34 +0000 Subject: [PATCH] Bug 17585: Replace ->get_account_lines with ->account And return a Koha::Account instead of a Koha::Account::Lines Signed-off-by: Kyle M Hall --- Koha/Patron.pm | 9 ++++----- t/db_dependent/Koha/Patrons.t | 22 +++++----------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index dc74c4457a..c1b5351eac 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -548,16 +548,15 @@ sub get_age { return $age; } -=head3 get_account_lines +=head3 account -my $fines = $patron->get_account_lines +my $account = $patron->account =cut -sub get_account_lines { +sub account { my ($self) = @_; - my $account_lines = $self->_result->accountlines; - return Koha::Account::Lines->_new_from_dbic($account_lines); + return Koha::Account->new( { patron_id => $self->borrowernumber } ); } =head3 type diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index b2ab2959d6..a5a718d96e 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 17; +use Test::More tests => 18; use Test::Warn; use DateTime; @@ -501,26 +501,14 @@ subtest 'get_age' => sub { $patron->delete; }; -subtest 'get_account_lines' => sub { - plan tests => 2; +subtest 'account' => sub { + plan tests => 1; my $patron = $builder->build({source => 'Borrower'}); - my $accountline_1 = $builder->build({ source => 'Accountline', - value => { borrowernumber => $patron->{borrowernumber}, - amount => 42, - amountoutstanding => 42 } - }); - my $accountline_2 = $builder->build({ source => 'Accountline', - value => { borrowernumber => $patron->{borrowernumber}, - amount => -13, - amountoutstanding => -13 } - }); - $patron = Koha::Patrons->find( $patron->{borrowernumber} ); - my $account_lines = $patron->get_account_lines; - is( $account_lines->count, 2, 'There should have 2 account lines for that patron' ); - is( ref($account_lines), 'Koha::Account::Lines', 'get_account_lines should return a Koha::Account::Lines object' ); + my $account = $patron->account; + is( ref($account), 'Koha::Account', 'account should return a Koha::Account object' ); $patron->delete; }; -- 2.39.5