From df58f291dbf97b16a473af032a69be1b87a73769 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 21 Jul 2020 12:26:55 +0200 Subject: [PATCH 1/3] Bug 26032: Add unit test Run prove t/db_dependent/Items.t Signed-off-by: Emmi Takkinen --- t/db_dependent/Items.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 53ac9b8d93..4f94041643 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -407,7 +407,7 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { }; subtest 'SearchItems test' => sub { - plan tests => 15; + plan tests => 17; $schema->storage->txn_begin; my $dbh = C4::Context->dbh; @@ -605,6 +605,29 @@ subtest 'SearchItems test' => sub { ($items, $total_results) = SearchItems($filter); is($total_results, 1, "Search items.issues issues = 0 returns result (items.issues defaults to 0)"); + # Is null + $filter = { + conjunction => 'AND', + filters => [ + { + field => 'new_status', + query => 0, + operator => '=' + }, + { + field => 'homebranch', + query => $library1->{branchcode}, + operator => '=', + }, + ], + }; + ($items, $total_results) = SearchItems($filter); + is($total_results, 0, 'found no item with new_status=0 without ifnull'); + + $filter->{filters}[0]->{ifnull} = 0; + ($items, $total_results) = SearchItems($filter); + is($total_results, 1, 'found all items of library1 with new_status=0 with ifnull = 0'); + $schema->storage->txn_rollback; }; -- 2.17.1