From 24002f91be4791080720f78410c74d44f3bf8010 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. --- .../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 c8c774d6e1..c1f6d42c60 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 => 57; + plan tests => 60; my $qb; @@ -449,6 +449,33 @@ subtest 'build_query tests' => sub { "query of boolean type field is not truncated even if QueryAutoTruncate is set" ); + # Reset SearchCancelAndInvalidISBNandISSN syspref + t::lib::Mocks::mock_preference( 'SearchCancelAndInvalidISBNandISSN', '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 SearchCancelAndInvalidISBNandISSN syspref + t::lib::Mocks::mock_preference( 'SearchCancelAndInvalidISBNandISSN', '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.2