From 0dd072437e69417fdf4e4d87210849755129f59e Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 1 Jul 2024 10:03:50 +0000 Subject: [PATCH] Bug 27919: (QA follow-up): Add unit tests prove t/db_dependent/Circulation/ReturnClaims.t Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- t/db_dependent/Circulation/ReturnClaims.t | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/ReturnClaims.t b/t/db_dependent/Circulation/ReturnClaims.t index 6fb1c8d176..2bb2a5c437 100755 --- a/t/db_dependent/Circulation/ReturnClaims.t +++ b/t/db_dependent/Circulation/ReturnClaims.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 4; use Test::MockModule; use Test::Warn; @@ -143,4 +143,34 @@ subtest 'Test Koha::Checkout::claim_returned, mark as returned' => sub { is( $checkout2->id, $checkout->id, "Checkout was found in the old_issues table"); }; +subtest 'Test Koha::Checkout::claim_returned should not update the itemlost status if it is already set' => sub { + plan tests => 2; + + t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue', 1 ); + my $item = $builder->build_sample_item( { itemlost => 0 } ); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $checkout = AddIssue( $patron, $item->barcode ); + + my $claim = $checkout->claim_returned( + { + created_by => $patron->borrowernumber, + notes => "Test note", + } + ); + my $updated_item = Koha::Items->find( $item->id ); + is( $updated_item->itemlost, 1, 'Itemlost was set by the return claim' ); + + my $item2 = $builder->build_sample_item( { itemlost => 2 } ); + my $checkout2 = AddIssue( $patron, $item->barcode ); + + my $claim2 = $checkout2->claim_returned( + { + created_by => $patron->borrowernumber, + notes => "Test note", + } + ); + my $updated_item2 = Koha::Items->find( $item2->id ); + is( $updated_item2->itemlost, 2, 'Itemlost was not set by the return claim as it already has an Itemlost status' ); +}; + $schema->storage->txn_rollback; -- 2.39.5