From feb9851202c0acd8ccbca2c6e227b92dcfb74ea3 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 24 Mar 2022 14:11:57 -1000 Subject: [PATCH] Bug 17748: (follow-up) Stronger unit tests Before this patch, unit tests perform an item search assuming there is no checked-out items in database. This is correct for a fresh reseted database. But if you checkout any item then prove t/db_dependent/Items.t it will fail. We can see in this file that other tests use filter on generated branchcode. This patch adds filter to items.homebranch --- t/db_dependent/Items.t | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 5aa9260a48..ab0fa8e66e 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -636,9 +636,19 @@ subtest 'SearchItems test' => sub { AddIssue( $patron_borrower, $item1->barcode ); # Search item where item is checked out $filter = { - field => 'onloan', - query => 'not null', - operator => 'is', + conjunction => 'AND', + filters => [ + { + field => 'onloan', + query => 'not null', + operator => 'is', + }, + { + field => 'homebranch', + query => $item1->homebranch, + operator => '=', + }, + ], }; ($items, $total_results) = SearchItems($filter); ok(scalar @$items == 1, 'found 1 checked out item'); @@ -648,7 +658,12 @@ subtest 'SearchItems test' => sub { sortby => 'availability', sortorder => 'DESC', }; - ($items, $total_results) = SearchItems(undef,$params); + $filter = { + field => 'homebranch', + query => $item1->homebranch, + operator => '=', + }; + ($items, $total_results) = SearchItems($filter,$params); is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability'); $schema->storage->txn_rollback; -- 2.35.1