From 671f27eeb18cd3683888b92e3a95384d04c47122 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Mon, 14 Sep 2026 10:08:11 +0000 Subject: [PATCH] Bug 41889: [Rmaint] Fix error in conflict resolution --- t/db_dependent/api/v1/checkouts.t | 111 ------------------------------ 1 file changed, 111 deletions(-) diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t index bcf2910a43..7df41b514b 100755 --- a/t/db_dependent/api/v1/checkouts.t +++ b/t/db_dependent/api/v1/checkouts.t @@ -601,116 +601,6 @@ subtest 'add checkout' => sub { $schema->storage->txn_rollback; }; -<<<<<<< HEAD -||||||| parent of 64bea0833a (Bug 41889: Update API to allow for null patron_id to be returned when listing checkouts) - -subtest 'renew with fine override (x-koha-override: debt_limit)' => sub { - plan tests => 15; - - $schema->storage->txn_begin; - - # Create a librarian with circulate permission - my $librarian = $builder->build_object( - { - class => 'Koha::Patrons', - value => { flags => 2 } # Superlibrarian - } - ); - my $password = 'thePassword123'; - $librarian->set_password( { password => $password, skip_validation => 1 } ); - my $userid = $librarian->userid; - - # Create a regular patron - my $patron = $builder->build_object( - { - class => 'Koha::Patrons', - value => { flags => 0 } - } - ); - - # Create a branch and set up userenv - my $branch = $builder->build( { source => 'Branch' } ); - t::lib::Mocks::mock_userenv( - { branchcode => $branch->{branchcode}, borrowernumber => $librarian->borrowernumber } ); - - # Set up circulation rules - Koha::CirculationRules->set_rules( - { - categorycode => undef, - itemtype => undef, - branchcode => undef, - rules => { - renewalperiod => 7, - renewalsallowed => 10, - issuelength => 5, - } - } - ); - - my $item = $builder->build_sample_item; - - # Check out the item - my $checkout = AddIssue( $patron, $item->barcode ); - - # Set FineNoRenewals to a low amount - t::lib::Mocks::mock_preference( 'FineNoRenewals', 5 ); - - # Add a fine that exceeds the limit - my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); - $account->add_debit( - { - amount => 10.00, - type => 'OVERDUE', - interface => 'test', - description => 'Test fine', - item_id => $item->itemnumber, - } - ); - - my $checkout_id = $checkout->id; - - # Test 1: Renewal should be blocked due to excessive fines - $t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout_id/renewal") - ->status_is(403) - ->json_like( '/error' => qr/too_much_owing/ ); - - # Test 2: Override should fail when AllowFineOverrideRenewing is disabled - t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 ); - - $t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } ) - ->status_is(403) - ->json_like( '/error' => qr/too_much_owing/ ); - - # Test 3: Override should succeed when AllowFineOverrideRenewing is enabled - t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 ); - - $t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } ) - ->status_is(201) - ->json_has('/due_date'); - - # Refresh checkout - $checkout = Koha::Checkouts->find($checkout_id); - - # Test 4: Test with /renewals endpoint (alternative endpoint) - # Add another checkout to test the other endpoint - my $item2 = $builder->build_sample_item; - my $checkout2 = AddIssue( $patron, $item2->barcode ); - my $checkout2_id = $checkout2->id; - - # Should be blocked without override - $t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals") - ->status_is(403) - ->json_like( '/error' => qr/too_much_owing/ ); - - # Should succeed with override - $t->post_ok( - "//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals" => { 'x-koha-override' => 'debt_limit' } ) - ->status_is(201) - ->json_has('/due_date'); - - $schema->storage->txn_rollback; -}; -======= subtest 'renew with fine override (x-koha-override: debt_limit)' => sub { plan tests => 15; @@ -873,4 +763,3 @@ subtest 'list checkouts that have been checked in and the patron has been delete $schema->storage->txn_rollback; }; ->>>>>>> 64bea0833a (Bug 41889: Update API to allow for null patron_id to be returned when listing checkouts)