Bug 35357: Enhance unit tests

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Fixed typo in test output.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Kyle Hall 2024-02-06 12:11:12 -05:00 committed by Katrin Fischer
parent 0eced80866
commit 285a0fc74d
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -2095,7 +2095,7 @@ subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub {
subtest 'Remove item from holds queue on checkout' => sub {
plan tests => 2;
plan tests => 4;
$schema->storage->txn_begin;
@ -2114,7 +2114,9 @@ subtest 'Remove item from holds queue on checkout' => sub {
}
);
my $item = $builder->build_sample_item( { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
my $item = $builder->build_sample_item( { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
my $item2 = $builder->build_sample_item(
{ homebranch => $lib->branchcode, holdingbranch => $lib->branchcode, biblionumber => $item->biblionumber } );
t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
@ -2132,15 +2134,27 @@ subtest 'Remove item from holds queue on checkout' => sub {
is(
Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 1,
"Item is found in the holds queue"
"One item is found in the holds queue"
);
AddIssue( $patron1, $item->barcode, dt_from_string );
my $hq_item = Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->next->item;
AddIssue( $patron1, $hq_item->barcode, dt_from_string );
is(
Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 0,
"Item is no longer found in the holds queue"
);
C4::HoldsQueue::CreateQueue();
is(
Koha::Hold::HoldsQueueItems->search( { itemnumber => $item2->id } )->count(), 1,
"One item is found in the holds queue"
);
my $hq_item2 = Koha::Hold::HoldsQueueItems->search( { itemnumber => $item2->id } )->next->item;
isnt( $hq_item->id, $hq_item2->id, "Item now targeted by the holds queue is not the same item." );
$schema->storage->txn_rollback;
};