From 9eb0d73d53ceeffebbcde10ecf8cafb472eeb4c1 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 Content-Type: text/plain; charset=utf-8 Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- 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 92e284fa41..021d80a65e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3039,8 +3039,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 97ca6492e2..8c4d4bf4c4 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3756,7 +3756,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); @@ -3799,6 +3799,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