From 0b85b76343ac31546f4695967256545ccb4de91c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 14 Dec 2018 12:47:11 -0300 Subject: [PATCH] Bug 21065: Add tests Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Account/Lines.t | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index eb8dfdd1c0..2e8f7f2105 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 => 4; +use Test::More tests => 5; use Test::Exception; use Koha::Account; @@ -268,3 +268,30 @@ subtest 'apply() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'Keep account info when a patron is deleted' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $item = $builder->build_object({ class => 'Koha::Items' }); + my $line = Koha::Account::Line->new( + { + borrowernumber => $patron->borrowernumber, + itemnumber => $item->itemnumber, + accounttype => "F", + amount => 10, + })->store; + + $item->delete; + $line = $line->get_from_storage; + is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); + + $patron->delete; + $line = $line->get_from_storage; + is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); + + $schema->storage->txn_rollback; +}; -- 2.19.2