From bd8272bebbfadd1ac523c0ad4a62d74b63af976f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Sep 2023 16:13:40 +0200 Subject: [PATCH] Bug 34846: Fix SIP/ILS.t if DB has been upgraded t/db_dependent/SIP/ILS.t .. 12/15 # Failed test 'Renewal succeeded' # at t/db_dependent/SIP/ILS.t line 346. # got: '0' # expected: '1' # Looks like you failed 1 test of 2. t/db_dependent/SIP/ILS.t .. 15/15 # Failed test 'renew' # at t/db_dependent/SIP/ILS.t line 348. # Looks like you failed 1 test of 15. Because renewalsallowed is 0 for upgraded DB, when it's 5 for new install. We need to set the value. Test plan: perl /kohadevbox/misc4dev/run_tests.pl --run-db-upgrade-only prove t/db_dependent/SIP/ILS.t Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5f55775f402d4f4b56ab82426588b202d6f327ce) Signed-off-by: Fridolin Somers (cherry picked from commit bb19ca161832d3c630523f03730eb2439063399f) Signed-off-by: Jacob O'Mara --- t/db_dependent/SIP/ILS.t | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/t/db_dependent/SIP/ILS.t b/t/db_dependent/SIP/ILS.t index e96dd4ce55..c63cbaea10 100755 --- a/t/db_dependent/SIP/ILS.t +++ b/t/db_dependent/SIP/ILS.t @@ -315,4 +315,46 @@ subtest renew_all => sub { isnt( $transaction->{screen_msg}, 'Invalid patron password.', "Empty password succeeds" ); }; +subtest renew => sub { + plan tests => 2; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + branchcode => $library->branchcode, + } + } + ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); + + Koha::CirculationRules->set_rule( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rule_name => 'renewalsallowed', + rule_value => '5', + } + ); + + my $item = $builder->build_sample_item( + { + library => $library->branchcode, + } + ); + + AddIssue( $patron->unblessed, $item->barcode, undef, 0 ); + my $checkout = $item->checkout; + ok( defined($checkout), "Successfully checked out an item prior to renewal" ); + + my $ils = C4::SIP::ILS->new( { id => $library->branchcode } ); + + my $transaction = $ils->renew( $patron->cardnumber, "", $item->barcode ); + + is( $transaction->{renewal_ok}, 1, "Renewal succeeded" ); + +}; + $schema->storage->txn_rollback; -- 2.39.5