From 4aa1026e4f0e36f5e6ac426fd0e21970cec96a20 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 23 Nov 2020 12:09:47 +0000 Subject: [PATCH] Bug 26518: (QA follow-up) Expect warnings, don't supress them Signed-off-by: Nick Clemens --- t/db_dependent/Biblio.t | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 309b8534c7..ac6a6a1255 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -19,6 +19,7 @@ use Modern::Perl; use Test::More tests => 15; use Test::MockModule; +use Test::Warn; use List::MoreUtils qw( uniq ); use MARC::Record; @@ -43,7 +44,7 @@ Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); my $builder = t::lib::TestBuilder->new; subtest 'AddBiblio' => sub { - plan tests => 3; + plan tests => 4; my $marcflavour = 'MARC21'; t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ); @@ -56,12 +57,9 @@ subtest 'AddBiblio' => sub { my $nb_biblios = Koha::Biblios->count; my ( $biblionumber, $biblioitemnumber ); - { - local *STDERR; - open STDERR, '>', '/dev/null'; - ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); - close STDERR; - } + warnings_like { ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ) } + [ qr/Data too long for column 'lccn'/, qr/Data too long for column 'lccn'/ ], + "expected warnings when adding too long LCCN"; is( $biblionumber, undef, 'AddBiblio returns undef for biblionumber if something went wrong' ); is( $biblioitemnumber, undef, -- 2.11.0