From cae6a3695214ad2c4b3319824afb434a0c41c537 Mon Sep 17 00:00:00 2001 From: Laura Escamilla Date: Tue, 19 Mar 2024 16:03:54 +0000 Subject: [PATCH] Bug 27753: Unit tests Signed-off-by: Andrew Fuerste Henry --- t/db_dependent/Circulation.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f35af9d754e..6ea30e1f211 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 70; +use Test::More tests => 71; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -2590,6 +2590,36 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { # TODO There are other tests to provide here }; + +subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub { + plan tests => 8; + t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); + t::lib::Mocks::mock_userenv({ branchcode => $library2->{branchcode} }); + t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue', 1 ); + t::lib::Mocks::mock_preference( 'AutoClaimReturnStatusOnCheckin', 1 ); + my $item = $builder->build_sample_item ({library=>$library2->{branchcode}}); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $checkout = AddIssue( $patron, $item->barcode ); + + my $claim = $checkout->claim_returned( + { + created_by => $patron->id, + notes => "Test note", + } + ); + is( $claim->issue_id, $checkout->id, "Claim issue id matches" ); + is( $claim->itemnumber, $item->id, "Claim itemnumber matches" ); + is( $claim->borrowernumber, $patron->id, "Claim borrowernumber matches" ); + is( $claim->notes, "Test note", "Claim notes match" ); + is( $claim->created_by, $patron->id, "Claim created_by matches" ); + ok( $claim->created_on, "Claim created_on is set" ); + + my ( $doreturn, $messages) = AddReturn ( $item->barcode, $library->{branchcode} ); + is (ref $messages->{ClaimAutoResolved}, 'Koha::Checkouts::ReturnClaim', "Claim auto resolved upon checkin"); + $claim->discard_changes; + ok( $claim->resolved_by, "Claim is resolved"); +}; + subtest 'MultipleReserves' => sub { plan tests => 3; -- 2.30.2