From c788719f7a58c40796820d84624dcca16aa1845e Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 14 Jun 2023 17:15:23 +0000 Subject: [PATCH] Bug 33500: Add tests for RecordLocalUseOnReturn To test: 1. Turn on RecordLocalUseOnReturn 2. prove -v /kohadevbox/koha/t/db_dependent/Circulation.t 3. Tests fail. 4. Apply patch 5. prove -v /kohadevbox/koha/t/db_dependent/Circulation.t 6. Tests pass. Signed-off-by: Sam Lau --- t/db_dependent/Circulation.t | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 3cd4ded868..5c91fb195b 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 => 66; +use Test::More tests => 67; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -5803,6 +5803,7 @@ subtest 'Tests for BlockReturnOfWithdrawnItems' => sub { plan tests => 1; t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1); + t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0); my $item = $builder->build_sample_item(); $item->withdrawn(1)->itemlost(1)->store; my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); @@ -5836,6 +5837,25 @@ subtest 'Tests for transfer not in transit' => sub { }; +subtest 'Tests for RecordLocalUseOnReturn' => sub { + + plan tests => 2; + + t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0); + my $item = $builder->build_sample_item(); + $item->withdrawn(1)->itemlost(1)->store; + my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); + is_deeply( + \@return, + [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], "RecordLocalUSeOnReturn is off, no local use recorded"); + + t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 1); + my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef ); + is_deeply( + \@return2, + [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded"); +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); -- 2.30.2