Bugzilla – Attachment 166258 Details for
Bug 36396
Link facet with authorised value category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36396: Add tests
Bug-36396-Add-tests.patch (text/plain), 3.83 KB, created by
Martin Renvoize (ashimema)
on 2024-05-07 11:11:33 UTC
(
hide
)
Description:
Bug 36396: Add tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-05-07 11:11:33 UTC
Size:
3.83 KB
patch
obsolete
>From 302c56160d048e0477447e8983b011ad83abefee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 7 May 2024 12:41:39 +0200 >Subject: [PATCH] Bug 36396: Add tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../Koha/SearchEngine/Elasticsearch/Search.t | 55 +++++++++++++------ > 1 file changed, 39 insertions(+), 16 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >index d5fae601ac6..64de5729b6e 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >@@ -19,10 +19,11 @@ use Modern::Perl; > > use Test::More tests => 14; > use t::lib::Mocks; >+use t::lib::TestBuilder; > > use Koha::SearchEngine::Elasticsearch::QueryBuilder; > use Koha::SearchEngine::Elasticsearch::Indexer; >- >+use Koha::SearchFields; > > my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); > $se->mock( 'get_elasticsearch_mappings', sub { >@@ -125,31 +126,53 @@ SKIP: { > is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value'); > > subtest "_convert_facets" => sub { >- plan tests => 2; >+ plan tests => 5; >+ >+ my $schema = Koha::Database->new()->schema(); >+ $schema->storage->txn_begin; >+ my $builder = t::lib::TestBuilder->new; > > my $es_facets = { > 'ln' => { >- 'sum_other_doc_count' => 0, >- 'buckets' => [ >- { >- 'doc_count' => 2, >- 'key' => 'eng' >- }, >- { >- 'doc_count' => 12, >- 'key' => '' >- } >- ], >- 'doc_count_error_upper_bound' => 0 >+ 'sum_other_doc_count' => 0, >+ 'buckets' => [ >+ { >+ 'doc_count' => 2, >+ 'key' => 'eng' >+ }, >+ { >+ 'doc_count' => 12, >+ 'key' => '' >+ } >+ ], >+ 'doc_count_error_upper_bound' => 0 > } > }; > > my $koha_facets = $searcher->_convert_facets($es_facets); >- is(@{$koha_facets->[0]->{facets}},1,"We only get one facet, blank is removed"); >+ is( @{ $koha_facets->[0]->{facets} }, 1, "We only get one facet, blank is removed" ); > > $es_facets->{ln}->{buckets}->[1]->{key} = '0'; > $koha_facets = $searcher->_convert_facets($es_facets); >- is(@{$koha_facets->[0]->{facets}},2,"We get two facets, '0' is not removed"); >+ is( @{ $koha_facets->[0]->{facets} }, 2, "We get two facets, '0' is not removed" ); >+ is( $koha_facets->[0]->{av_cat}, undef, "Not linked with an authorised value category" ); >+ >+ my $av_cat = $builder->build_object( { class => 'Koha::AuthorisedValueCategories' } ); >+ Koha::SearchFields->find( { name => 'ln' } )->update( { authorised_value_category => $av_cat->category_name } ); >+ $builder->build_object( >+ { >+ class => 'Koha::AuthorisedValues', >+ value => { category => $av_cat->category_name, authorised_value => 'eng', lib_opac => 'English' } >+ } >+ ); >+ $koha_facets = $searcher->_convert_facets($es_facets); >+ is( $koha_facets->[0]->{av_cat}, $av_cat->category_name, "Linked with an authorised value category" ); >+ is( >+ $koha_facets->[0]->{facets}->[1]->{facet_label_value}, "English", >+ "Value of the facet replaced with AV's description" >+ ); >+ >+ $schema->storage->txn_rollback; > > }; > } >-- >2.45.0
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 36396
:
163685
|
163686
|
163687
|
163688
|
163689
|
163690
|
163705
|
163776
|
163777
|
163778
|
163779
|
163780
|
163781
|
163782
|
166246
|
166247
|
166248
|
166249
|
166250
|
166251
|
166252
|
166254
| 166258