Bug 37964: Add units test

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Amended-by: Jonathan Druart
Tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Fridolin Somers 2024-09-19 16:44:07 +02:00 committed by Martin Renvoize
parent f27d58f72f
commit 4447352f81
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 12 additions and 1 deletions

View File

@ -1387,15 +1387,26 @@ subtest 'host_items() tests' => sub {
is( $host_items->count, 0 );
subtest 'test host_items param in items()' => sub {
plan tests => 4;
plan tests => 5;
t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', 1 );
my $items = $biblio->items;
is( $items->count, 1, "Without host_items param we only get the items on the biblio");
$items = $biblio->items({ host_items => 1 });
is( $items->count, 3, "With param host_items we get the biblio items plus analytics");
is( ref($items), 'Koha::Items', "We correctly get an Items object");
is_deeply( [ $items->get_column('itemnumber') ],
[ $item_1->itemnumber, $host_item_1->itemnumber, $host_item_2->itemnumber ] );
t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', 0 );
$items = $biblio->items( { host_items => 1 } );
is(
$items->count, 1,
"With host_items param but EasyAnalyticalRecords disabled we only get the items on the biblio"
);
};
$schema->storage->txn_rollback;