From 8d2788905dad26aa91c56b70332828c567d8be33 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 15 Jul 2025 15:06:46 +0200 Subject: [PATCH] Bug 40390: Remove warnings from t/db_dependent/Biblio.t t/db_dependent/Biblio.t .. 2/25 Finding auth type GENRE/FORM at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. t/db_dependent/Biblio.t .. 12/25 Finding auth type TOPIC_TERM at t/db_dependent/Biblio.t line 300. Finding auth type TOPIC_TERM at t/db_dependent/Biblio.t line 300. Finding auth type TOPIC_TERM at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. Finding auth type PERSO_NAME at t/db_dependent/Biblio.t line 300. t/db_dependent/Biblio.t .. ok --- t/db_dependent/AuthorisedValues.t | 3 ++- t/db_dependent/Biblio.t | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t index 559cd2ec74a..069614504ab 100755 --- a/t/db_dependent/AuthorisedValues.t +++ b/t/db_dependent/AuthorisedValues.t @@ -1,7 +1,8 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 17; +use Test::More tests => 18; +use Test::NoWarnings; use Test::Exception; use Try::Tiny; diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 1f08417b932..e34c00e6da3 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,8 @@ use Modern::Perl; -use Test::More tests => 25; +use Test::More tests => 26; +use Test::NoWarnings; use Test::MockModule; use Test::Warn; use List::MoreUtils qw( uniq ); @@ -293,11 +294,12 @@ subtest "Test caching of authority types in LinkBibHeadingsToAuthorities" => sub } ); my $authorities_type = Test::MockModule->new('Koha::Authority::Types'); + my $found_auth_type = {}; $authorities_type->mock( 'find', sub { my ( $self, $params ) = @_; - warn "Finding auth type $params"; + $found_auth_type->{$params}++; return $authorities_type->original("find")->( $self, $params ); } ); @@ -305,17 +307,13 @@ subtest "Test caching of authority types in LinkBibHeadingsToAuthorities" => sub my $field1 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical realism' ); my $field2 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical falsism' ); $marc_record->append_fields( ( $field1, $field2 ) ); - my ( $num_changed, $results ); - warning_like { ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ) } - qr/Finding auth type GENRE\/FORM/, - "Type fetched only once"; + my ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ); + is_deeply( $found_auth_type, { "GENRE/FORM" => 1 }, "Type fetched only once" ); my $gf_type = $cache->get_from_cache("LinkBibHeadingsToAuthorities:AuthorityType:GENRE/FORM"); ok( $gf_type, "GENRE/FORM type is found in cache" ); - warning_like { ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ) } - undef, - "Type not fetched a second time"; - + ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ); + is_deeply( $found_auth_type, { "GENRE/FORM" => 1 }, "Type not fetched a second time" ); }; # Mocking variables -- 2.34.1