Bugzilla – Attachment 141429 Details for
Bug 17170
Add the ability to create 'saved searches' for use as filters when searching the catalog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17170: Unit tests
Bug-17170-Unit-tests.patch (text/plain), 4.31 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-10-06 14:27:13 UTC
(
hide
)
Description:
Bug 17170: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-10-06 14:27:13 UTC
Size:
4.31 KB
patch
obsolete
>From 9f43420bc6843c6f36f994459286c14b05bb3075 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 13 Apr 2022 12:17:25 +0000 >Subject: [PATCH] Bug 17170: Unit tests > >Sponsored-by: Sponsored by: Round Rock Public Library [https://www.roundrocktexas.gov/departments/library/] > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../SearchEngine/Elasticsearch/QueryBuilder.t | 28 ++++++++++++++++++- > .../Koha/SearchEngine/Zebra/QueryBuilder.t | 27 +++++++++++++++++- > 2 files changed, 53 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index 27d11c04da0..8488af5f562 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -22,12 +22,13 @@ use Test::Exception; > use Test::Warn; > use t::lib::Mocks; > use t::lib::TestBuilder; >-use Test::More tests => 7; >+use Test::More tests => 8; > > use List::Util qw( all ); > > use Koha::Database; > use Koha::SearchEngine::Elasticsearch::QueryBuilder; >+use Koha::SearchFilters; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -783,6 +784,31 @@ subtest 'build_query_compat() SearchLimitLibrary tests' => sub { > > }; > >+subtest "Handle search filters" => sub { >+ plan tests => 4; >+ >+ my $qb; >+ >+ ok( >+ $qb = Koha::SearchEngine::Elasticsearch::QueryBuilder->new({ 'index' => 'biblios' }), >+ 'Creating new query builder object for biblios' >+ ); >+ >+ my $filter = Koha::SearchFilter->new({ >+ name => "test", >+ query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|, >+ limits => q|{"limits":["mc-itype,phr:BK","available"]}|, >+ })->store; >+ my $filter_id = $filter->id; >+ >+ my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] ); >+ >+ is( $limit,q{(itype:("BK")) AND (onloan:false) AND (((cat) AND title:(bat) OR author:(rat)))},"Limit correctly formed"); >+ is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded"); >+ is( $limit_desc,q{(itype:("BK")) AND (onloan:false) AND (((cat) AND title:(bat) OR author:(rat)))},"Limit description is correctly expanded"); >+ >+}; >+ > subtest "_convert_sort_fields() tests" => sub { > plan tests => 3; > >diff --git a/t/db_dependent/Koha/SearchEngine/Zebra/QueryBuilder.t b/t/db_dependent/Koha/SearchEngine/Zebra/QueryBuilder.t >index 02c129aa643..2653e45acd5 100755 >--- a/t/db_dependent/Koha/SearchEngine/Zebra/QueryBuilder.t >+++ b/t/db_dependent/Koha/SearchEngine/Zebra/QueryBuilder.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use t::lib::Mocks; > use t::lib::TestBuilder; > use Test::MockModule; >@@ -96,3 +96,28 @@ subtest 'build_query_compat() SearchLimitLibrary tests' => sub { > is( $limit_cgi, "&limit=multibranchlimit%3A$groupid", "Limit cgi does not get expanded"); > > }; >+ >+subtest "Handle search filters" => sub { >+ plan tests => 4; >+ >+ my $qb; >+ >+ ok( >+ $qb = Koha::SearchEngine::Zebra::QueryBuilder->new({ 'index' => 'biblios' }), >+ 'Creating new query builder object for biblios' >+ ); >+ >+ my $filter = Koha::SearchFilter->new({ >+ name => "test", >+ query => q|{"operands":["cat","bat","rat"],"indexes":["kw","ti","au"],"operators":["AND","OR"]}|, >+ limits => q|{"limits":["mc-itype,phr:BK","available"]}|, >+ })->store; >+ my $filter_id = $filter->id; >+ >+ my ( undef, undef, undef, undef, undef, $limit, $limit_cgi, $limit_desc ) = $qb->build_query_compat( undef, undef, undef, ["search_filter:$filter_id"] ); >+ >+ is( $limit,q{(kw=(cat) AND ti=(bat) OR au=(rat)) and (mc-itype,phr=BK) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit correctly formed"); >+ is( $limit_cgi,"&limit=search_filter%3A$filter_id","CGI limit is not expanded"); >+ is( $limit_desc,q{(kw=(cat) AND ti=(bat) OR au=(rat)) and (mc-itype,phr=BK) and (( (allrecords,AlwaysMatches='') and (not-onloan-count,st-numeric >= 1) and (lost,st-numeric=0) ))},"Limit description is correctly expanded"); >+ >+}; >-- >2.34.1
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 17170
:
133263
|
133264
|
133265
|
133266
|
133267
|
133268
|
133269
|
133270
|
133361
|
133376
|
137027
|
137028
|
137029
|
137030
|
137031
|
137032
|
137033
|
137034
|
137035
|
137036
|
137186
|
137187
|
137188
|
137189
|
137190
|
137191
|
137192
|
137193
|
137194
|
137195
|
137808
|
137809
|
137810
|
137811
|
137812
|
137813
|
137814
|
137815
|
137816
|
137817
|
138505
|
138506
|
138507
|
138508
|
138509
|
138510
|
138511
|
138512
|
138513
|
138514
|
139948
|
139949
|
139950
|
139951
|
139952
|
139953
|
139954
|
139955
|
139956
|
139957
|
141228
|
141229
|
141230
|
141231
|
141232
|
141233
|
141234
|
141235
|
141236
|
141237
|
141316
|
141317
|
141318
|
141319
|
141320
|
141321
|
141322
|
141323
|
141324
|
141325
|
141326
|
141327
|
141328
|
141348
|
141349
|
141350
|
141351
|
141352
|
141353
|
141354
|
141355
|
141356
|
141357
|
141358
|
141359
|
141360
|
141422
|
141423
|
141424
|
141425
|
141426
|
141427
|
141428
|
141429
|
141430
|
141431
|
141432
|
141433
|
141434
|
141435
|
141436
|
141437
|
141438
|
141461
|
141462
|
142365
|
142367
|
142368
|
142369
|
142370
|
142371
|
142372
|
142373
|
142374
|
142375
|
142376
|
142377
|
142378
|
142379
|
142380
|
142381
|
142382
|
142383
|
142384
|
142385
|
142494
|
142498