From 803710acef05f5a9a54a4498a171b012e3e1d4e8 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 Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer --- .../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 4b3c4f0b2f..a320b445c8 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; @@ -522,6 +522,33 @@ subtest 'build_query tests' => sub { # Note that (colons/equal signs)/spaces glued to words are not removed by the feature under test but before. }; + # 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