From 3329cc028687bbb6f22c4de3e9f76254d0825a5b 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 This patch adds a test to ensure database relations do not cascade deletions when a cash register is deleted. Signed-off-by: Kyle M Hall --- 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 a2a12c16f0..667071f0a2 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -551,9 +551,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; @@ -566,6 +566,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, @@ -575,6 +577,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; @@ -590,6 +593,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