From df53867563e232ca080ed198b9ed64d0e44e8522 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 Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart (cherry picked from commit e05ad0c1f827c9670f7bfb7f2112c380f0da5c04) Signed-off-by: Fridolin Somers --- 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 f2a91d208c..2bfd229360 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3040,8 +3040,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 6258ed80a8..97bf3ef6c6 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -3739,7 +3739,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); @@ -3782,6 +3782,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.39.5