From e0b1c66c44487d222d919f1c2f6cc4c1e6c18c8c Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 21 Jul 2020 12:26:55 +0200 Subject: [PATCH] Bug 26032: Add unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run prove t/db_dependent/Items.t Signed-off-by: Emmi Takkinen Signed-off-by: Séverine QUEUNE --- 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 53ac9b8..4f94041 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.1.4