From 881d23c2a48becd055d5ccb0148d236e4e8b556d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 6 Mar 2019 08:08:19 -0500 Subject: [PATCH] Bug 22008: Fixes to make unit tests pass Signed-off-by: Kyle M Hall Signed-off-by: Josef Moravec --- installer/data/mysql/atomicupdate/bug_22008.perl | 4 ++-- t/db_dependent/Koha/Account/Lines.t | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_22008.perl b/installer/data/mysql/atomicupdate/bug_22008.perl index 7f6098e65e..8a398bb25d 100644 --- a/installer/data/mysql/atomicupdate/bug_22008.perl +++ b/installer/data/mysql/atomicupdate/bug_22008.perl @@ -3,8 +3,8 @@ if( CheckVersion( $DBversion ) ) { # Add constraint for manager_id unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_borrowers_2' ) ) { - $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL;"); - $dbh->do("UPDATE accountlines a LEFT JOIN borrowers b ON ( a.manager_id = b.borrowernumber) SET a.manager_id = NULL WHERE b.borrowernumber IS NULL; + $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL"); + $dbh->do("UPDATE accountlines a LEFT JOIN borrowers b ON ( a.manager_id = b.borrowernumber) SET a.manager_id = NULL WHERE b.borrowernumber IS NULL"); $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"); } diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t index bf5634a349..aafda5f43d 100755 --- a/t/db_dependent/Koha/Account/Lines.t +++ b/t/db_dependent/Koha/Account/Lines.t @@ -285,7 +285,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub my $item = $builder->build_object({ class => 'Koha::Items' }); my $issue = $builder->build_object( { - class => 'Koha::Checkout', + class => 'Koha::Checkouts', value => { itemnumber => $item->itemnumber } } ); @@ -298,6 +298,7 @@ subtest 'Keep account info when related patron, staff or item is deleted' => sub amount => 10, })->store; + $issue->delete; $item->delete; $line = $line->get_from_storage; is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); -- 2.11.0