From 04e6a7ceb96c02c251cb9ef7642b3a32db5dc024 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 16 May 2019 08:49:22 +0100 Subject: [PATCH] Bug 19919: Unit Tests Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Account/Lines.t | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index 3856f6ef14..94fc45c302 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 9; use Test::Exception; use C4::Circulation qw/AddIssue AddReturn/; @@ -34,6 +34,35 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; +subtest 'patron() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $library = $builder->build( { source => 'Branch' } ); + my $patron = $builder->build( { source => 'Borrower' } ); + + my $line = Koha::Account::Line->new( + { + borrowernumber => $patron->{borrowernumber}, + accounttype => "OVERDUE", + status => "RETURNED", + amount => 10, + interface => 'commandline', + })->store; + + my $account_line_patron = $line->patron; + is( ref( $account_line_patron ), 'Koha::Patron', 'Koha::Account::Line->patron should return a Koha::Patron' ); + is( $line->borrowernumber, $account_line_patron->borrowernumber, 'Koha::Account::Line->patron should return the correct item' ); + + $line->borrowernumber(undef)->store; + is( $line->patron, undef, 'Koha::Account::Line->patron should return undef if no patron linked' ); + + $schema->storage->txn_rollback; +}; + + subtest 'item() tests' => sub { plan tests => 3; -- 2.20.1