From 4447352f8121c6c0da4df47f08e48c29bfa35904 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 19 Sep 2024 16:44:07 +0200 Subject: [PATCH] Bug 37964: Add units test Signed-off-by: Lucas Gass Amended-by: Jonathan Druart Tidy Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Biblio.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 7226421d23..6af083b276 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -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; -- 2.39.5