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 <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2024-03-11 23:34:55 +00:00 committed by Katrin Fischer
parent 95ff045c65
commit 1123d26d09
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 20 additions and 1 deletions

View File

@ -6343,21 +6343,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 {