From 2fc6a6db1cde85792230da57128f475011eb0dab Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 24 Dec 2020 12:22:49 +0000 Subject: [PATCH] Bug 26457: Unit test --- C4/Circulation.pm | 4 +++- t/db_dependent/Circulation.t | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 1221d8dedc..fc651d1f19 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3085,8 +3085,10 @@ sub AddRenewal { AND itemnumber=?" ); + eval{ $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber ); - if ( $sth->err ){ + }; + if( $sth->err ){ Koha::Exceptions::Checkout::FailedRenewal->throw( error => 'Update of issue# ' . $issue->issue_id . ' failed with error: ' . $sth->errstr ); diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f29c175aef..f1afd087e7 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3694,7 +3694,7 @@ subtest 'AddReturn should clear items.onloan for unissued items' => sub { subtest 'AddRenewal and AddIssuingCharge tests' => sub { - plan tests => 12; + plan tests => 13; t::lib::Mocks::mock_preference('item-level_itypes', 1); @@ -3737,6 +3737,11 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { # Check the item out AddIssue( $patron->unblessed, $item->barcode ); + + throws_ok { + AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); + } 'Koha::Exceptions::Checkout::FailedRenewal', 'Exception is thrown when renewal update to issues fails'; + t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); my %params_renewal = ( -- 2.11.0