Bug 22008: Fixes to make unit tests pass
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 6 Mar 2019 13:08:19 +0000 (08:08 -0500)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 22 Mar 2019 20:02:45 +0000 (20:02 +0000)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

installer/data/mysql/atomicupdate/bug_22008.perl
t/db_dependent/Koha/Account/Lines.t

index 7f6098e..8a398bb 100644 (file)
@@ -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");
     }
 
index bf5634a..aafda5f 100755 (executable)
@@ -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");