From 859dd50f07b525808237dc38c2e2d4f372b68b3c Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Thu, 16 May 2024 13:29:10 +0000 Subject: [PATCH] Bug 36798: Unit tests Added unit tests. Signed-off-by: Roman Dolny --- .../SearchEngine/Elasticsearch/QueryBuilder.t | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t index cf36311dfe..bd9f30f75a 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -219,7 +219,7 @@ subtest 'build_authorities_query_compat() tests' => sub { }; subtest 'build_query tests' => sub { - plan tests => 58; + plan tests => 61; my $qb; @@ -457,6 +457,33 @@ subtest 'build_query tests' => sub { "ISBD punctualtion and problematic characters properly removed" ); + # Reset SearchCancelledAndInvalidISBNandISSN syspref + t::lib::Mocks::mock_preference( 'SearchCancelledAndInvalidISBNandISSN', '0' ); + + ( undef, $query ) = $qb->build_query_compat( undef, ['nb:"9780141930848"'] ); + is( + $query->{query}{query_string}{query}, + '(isbn:"9780141930848")', + "nb query transformed into isbn search field" + ); + + # Set SearchCancelledAndInvalidISBNandISSN syspref + t::lib::Mocks::mock_preference( 'SearchCancelledAndInvalidISBNandISSN', '1' ); + + ( undef, $query ) = $qb->build_query_compat( undef, ['nb:"9780141930848"'] ); + is( + $query->{query}{query_string}{query}, + '(isbn-all:"9780141930848")', + "nb query transformed into isbn-all search field" + ); + + ( undef, $query ) = $qb->build_query_compat( undef, ['nb:"9780141930848" ns:"1089-6891"'] ); + is( + $query->{query}{query_string}{query}, + '(isbn-all:"9780141930848" issn-all:"1089-6891")', + "nb and ns query transformed into isbn-all and issn-all search field" + ); + ( undef, $query ) = $qb->build_query_compat( undef, ['J.R.R'] ); is( $query->{query}{query_string}{query}, -- 2.39.5