Bugzilla – Attachment 178042 Details for
Bug 39020
Search filters can't parse query in some instances
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39020: Add tests
Bug-39020-Add-tests.patch (text/plain), 2.89 KB, created by
Lisette Scheer
on 2025-02-13 18:11:33 UTC
(
hide
)
Description:
Bug 39020: Add tests
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2025-02-13 18:11:33 UTC
Size:
2.89 KB
patch
obsolete
>From 19ebac0898ea6178eefc974ab53fc7eba8a07b4f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 10 Feb 2025 14:10:46 +0100 >Subject: [PATCH] Bug 39020: Add tests > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Koha/SearchFilters.t | 30 +++++++++++++++++++++++++---- > 1 file changed, 26 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchFilters.t b/t/db_dependent/Koha/SearchFilters.t >index 81a304ba273..b576e8f545a 100755 >--- a/t/db_dependent/Koha/SearchFilters.t >+++ b/t/db_dependent/Koha/SearchFilters.t >@@ -20,6 +20,7 @@ > use Modern::Perl; > > use Test::More tests => 4; >+use JSON qw( encode_json ); > > use Koha::Database; > use Koha::SearchFilters; >@@ -30,7 +31,8 @@ use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >-my $original_count = Koha::SearchFilters->count(); >+my $original_count = Koha::SearchFilters->search->count(); >+my $original_count_opac = Koha::SearchFilters->search( { opac => 1 } )->count(); > > my $search_filter = Koha::SearchFilter->new( > { >@@ -44,18 +46,18 @@ my $search_filter = Koha::SearchFilter->new( > > is( Koha::SearchFilters->search()->count(), $original_count + 1, "New filter is added" ); > is( >- Koha::SearchFilters->search( { opac => 1 } )->count(), $original_count + 1, >+ Koha::SearchFilters->search( { opac => 1 } )->count(), $original_count_opac + 1, > "Searching by opac returns the filter if set" > ); > $search_filter->opac(0)->store(); > is( >- Koha::SearchFilters->search( { opac => 1 } )->count(), $original_count, >+ Koha::SearchFilters->search( { opac => 1 } )->count(), $original_count_opac, > "Searching by opac doesn't return the filter if not set" > ); > > subtest 'expand_filter tests' => sub { > >- plan tests => 2; >+ plan tests => 4; > > my $search_filter = Koha::SearchFilter->new( > { >@@ -72,6 +74,26 @@ subtest 'expand_filter tests' => sub { > is_deeply( $limits, [ 'mc-itype,phr:BK', 'fic:0' ], "Limit from filter is correctly expanded" ); > is( $query_limit, '(su=(programming) OR su=(internet))', "Query from filter is correctly expanded and grouped" ); > >+ my $empty_query = { >+ indexes => [ ("kw") x 3 ], >+ operands => [ ("") x 3 ], >+ operators => [], >+ }; >+ $search_filter = Koha::SearchFilter->new( >+ { >+ name => "Test", >+ query => encode_json($empty_query), >+ limits => q|{"limits":["mc-itype,phr:BK","fic:0"]}|, >+ opac => 1, >+ staff_client => 1 >+ } >+ )->store; >+ >+ ( $limits, $query_limit ) = $search_filter->expand_filter(); >+ >+ is_deeply( $limits, [ 'mc-itype,phr:BK', 'fic:0' ], "Limit from filter is correctly expanded" ); >+ is( $query_limit, '', "Empty query does not generate anything" ); >+ > }; > > $schema->storage->txn_rollback; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39020
:
177471
|
177490
|
177689
|
177690
|
177956
| 178042