From 3dbb9a75f3fe6074a4573ae9d1a62a1128da8e05 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 22 Aug 2019 09:10:51 +0100 Subject: [PATCH] Bug 23355: Add accountline deletion test --- t/db_dependent/Koha/Account/Lines.t | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index 9b8e4fa724..c92505813f 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -323,9 +323,9 @@ subtest 'apply() tests' => sub { $schema->storage->txn_rollback; }; -subtest 'Keep account info when related patron, staff or item is deleted' => sub { +subtest 'Keep account info when related patron, staff, item or cash_register is deleted' => sub { - plan tests => 3; + plan tests => 4; $schema->storage->txn_begin; @@ -338,6 +338,8 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub value => { itemnumber => $item->itemnumber } } ); + my $register = $builder->build_object({ class => 'Koha::Cash::Registers' }); + my $line = Koha::Account::Line->new( { borrowernumber => $patron->borrowernumber, @@ -347,6 +349,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub status => "RETURNED", amount => 10, interface => 'commandline', + register_id => $register->id })->store; $issue->delete; @@ -362,6 +365,10 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub $line = $line->get_from_storage; is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); + $register->delete; + $line = $line->get_from_storage; + is( $line->register_id, undef, "The account line should not be deleted when the related cash register is delete"); + $schema->storage->txn_rollback; }; -- 2.20.1