From feb6ac0cffbe2c419521783a90af9c09fd3f69c7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 11 Aug 2021 07:59:59 +0100 Subject: [PATCH] Bug 11175: (QA follow-up) Rename back to get_marc_components --- C4/XSLT.pm | 2 +- Koha/Biblio.pm | 14 +++++++------- catalogue/detail.pl | 2 +- opac/opac-detail.pl | 2 +- t/db_dependent/Koha/Biblio.t | 18 +++++++++--------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index c0c7098bf6..ee9fbf8fba 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -286,7 +286,7 @@ sub XSLTParse4Display { # possibly show analytics link in Detail views if ($xslsyspref =~ m/Details/) { $biblio //= Koha::Biblios->find( $biblionumber ); - my $components = $biblio->get_marc_analytics(); + my $components = $biblio->get_marc_components(); $variables->{show_analytics_link} = ( scalar @{$components} == 0 ) ? 0 : 1; my $showcomp = C4::Context->preference('ShowComponentRecords'); diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 5870ddea65..d135387da1 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -497,21 +497,21 @@ sub suggestions { return Koha::Suggestions->_new_from_dbic( $suggestions_rs ); } -=head3 get_marc_analytics +=head3 get_marc_components - my $analytics = $self->get_marc_analytics(); + my $components = $self->get_marc_components(); -Returns an array of MARCXML data, which are analytic parts of +Returns an array of MARCXML data, which are component parts of this object (MARC21 773$w points to this) =cut -sub get_marc_analytics { +sub get_marc_components { my ($self, $max_results) = @_; return [] if (C4::Context->preference('marcflavour') ne 'MARC21'); - my $searchstr = $self->get_analytics_query; + my $searchstr = $self->get_components_query; if (defined($searchstr)) { my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); @@ -522,13 +522,13 @@ sub get_marc_analytics { return $self->{_components} || []; } -=head2 get_analytics_query +=head2 get_components_query Returns a query which can be used to search for all component parts of MARC21 biblios =cut -sub get_analytics_query { +sub get_components_query { my ($self) = @_; my $marc = $self->metadata->record; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index c41aa2c455..9672b782ec 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -213,7 +213,7 @@ foreach my $subscription (@subscriptions) { # Get component parts details my $showcomp = C4::Context->preference('ShowComponentRecords'); if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { - if ( my $components = $biblio->get_marc_analytics(300) ) { + if ( my $components = $biblio->get_marc_components(300) ) { my $xslparts = C4::Context->preference('XSLTResultsDisplay') || "default"; if ( $xslparts ) { my $parts; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 040787434c..9bda12ed1b 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -660,7 +660,7 @@ my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 5 # Get component parts details my $showcomp = C4::Context->preference('ShowComponentRecords'); if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { - if ( my $components = $biblio->get_marc_analytics(300) ) { + if ( my $components = $biblio->get_marc_components(300) ) { my $xslparts = C4::Context->preference('OPACXSLTResultsDisplay') || "default"; if ( $xslparts ) { my $parts; diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index e9c234af76..be951ee808 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -503,7 +503,7 @@ subtest 'suggestions() tests' => sub { $schema->storage->txn_rollback; }; -subtest 'get_marc_analytics() tests' => sub { +subtest 'get_marc_components() tests' => sub { plan tests => 3; @@ -515,13 +515,13 @@ subtest 'get_marc_analytics() tests' => sub { my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); $search_mod->mock( 'simple_search_compat', \&search_component_record2 ); - my @components = $host_biblio->get_marc_analytics; + my @components = $host_biblio->get_marc_components; is( ref(\@components), 'ARRAY', 'Return type is correct' ); is_deeply( [@components], [[]], - '->get_marc_analytics returns an empty ARRAY' + '->get_marc_components returns an empty ARRAY' ); $search_mod->unmock( 'simple_search_compat'); @@ -529,16 +529,16 @@ subtest 'get_marc_analytics() tests' => sub { my $component_record = component_record1()->as_xml(); is_deeply( - $host_biblio->get_marc_analytics, + $host_biblio->get_marc_components, [($component_record)], - '->get_marc_analytics returns the related component part record' + '->get_marc_components returns the related component part record' ); $search_mod->unmock( 'simple_search_compat'); $schema->storage->txn_rollback; }; -subtest 'get_analytics_query' => sub { +subtest 'get_components_query' => sub { plan tests => 3; my $biblio = $builder->build_sample_biblio(); @@ -546,7 +546,7 @@ subtest 'get_analytics_query' => sub { my $record = $biblio->metadata->record; t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); - is($biblio->get_analytics_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); + is($biblio->get_components_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); my $marc_001_field = MARC::Field->new('001', $biblionumber); @@ -554,14 +554,14 @@ subtest 'get_analytics_query' => sub { C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber); - is($biblio->get_analytics_query, "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode"); + is($biblio->get_components_query, "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode"); my $marc_003_field = MARC::Field->new('003', 'OSt'); $record->append_fields($marc_003_field); C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber); - is($biblio->get_analytics_query, "((rcn:$biblionumber AND cni:OSt) OR rcn:OSt $biblionumber) AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled with MarcOrgCode"); + is($biblio->get_components_query, "((rcn:$biblionumber AND cni:OSt) OR rcn:OSt $biblionumber) AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled with MarcOrgCode"); }; subtest 'orders() and active_orders() tests' => sub { -- 2.20.1