From e1106e2184ace57dca4b7db10c80df0ee245ded7 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 11 Mar 2024 23:34:55 +0000 Subject: [PATCH] Bug 16122: Add unit test To test: 1. Apply patch, updatedatabase & schema, restart all Services 2. Go to Administration > Table setting. Find the holdings table ( Catalog > holdings_table ) and turn the local use column on. 3. Go to an item record and notice the column 'Local uses' 4. Turn the system preference RecordLocalUseOnReturn Off. 5. Check in an item that is not checkout out. No local use should be recorded for the item. 6. Turn RecordLocalUseOnReturn on and check in an item that is not checked out. Local use on that item should increment by 1. 7. Create a statistical patron and check an item out to them. Local use should increment by 1. 8. Go to /api/v1/items?external_id={barcode} and make sure the numbers for localuse look correct. To test maintainence script: 1. Without the patch, have RecordLocalUseOnReturn on. 2. Check in some items to record localuse in the stats table. Keep note of those stats. 3. Apply the patches, updatedatabase. 4. Run the maintenance script, perl update_localuse_from_statistics.pl 5. Now check that items.localuse is congruent with what is in the stats table Signed-off-by: Andrew Fuerste Henry Signed-off-by: Martin Renvoize --- t/db_dependent/Circulation.t | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f35af9d754e..c56bee8b91a 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -6288,21 +6288,40 @@ subtest 'Tests for transfer not in transit' => sub { subtest 'Tests for RecordLocalUseOnReturn' => sub { - plan tests => 2; + plan tests => 5; t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0); my $item = $builder->build_sample_item(); + + my $item_2 = $builder->build_sample_item( + { + onloan => undef, + } + ); + $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"); + AddReturn( $item_2->barcode, $item_2->homebranch ); + $item_2->discard_changes; # refresh + is( $item_2->localuse, undef , 'Without RecordLocalUseOnReturn no localuse is 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"); + + AddReturn( $item_2->barcode, $item_2->homebranch ); + $item_2->discard_changes; # refresh + is( $item_2->localuse, 1 , 'With RecordLocalUseOnReturn localuse is recorded.'); + + AddReturn( $item_2->barcode, $item_2->homebranch ); + $item_2->discard_changes; # refresh + is( $item_2->localuse, 2 , 'With RecordLocalUseOnReturn localuse is recorded.'); }; subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { -- 2.44.0