Bugzilla – Attachment 184381 Details for
Bug 40387
t/db_dependent/Koha/EDI.t generates warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40387: Add Test::NoWarnings and replace carp with Koha::Logger
Bug-40387-Add-TestNoWarnings-and-replace-carp-with.patch (text/plain), 3.50 KB, created by
Martin Renvoize (ashimema)
on 2025-07-18 13:48:24 UTC
(
hide
)
Description:
Bug 40387: Add Test::NoWarnings and replace carp with Koha::Logger
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-18 13:48:24 UTC
Size:
3.50 KB
patch
obsolete
>From d4fc86bafa4e53835db24ac7eabc481824036dd7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 18 Jul 2025 14:18:08 +0100 >Subject: [PATCH] Bug 40387: Add Test::NoWarnings and replace carp with > Koha::Logger > >This patch adds Test::NoWarnings to our EDI unit tests. In doing so, it >reminded me that we still had some old carp style error handling in the >process_quote section and that we shoudl replace those with calls to >Koha::Logger instead. > >Changes made: >1. Added Test::NoWarnings import to catch any warnings >2. Replace 'carp "Message"' appropriately with > '$logger->warn("Message")' >--- > Koha/EDI.pm | 9 +++++---- > t/db_dependent/Koha/EDI.t | 27 +++++++++------------------ > 2 files changed, 14 insertions(+), 22 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 4a36f15b384..58b3209fd14 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -21,7 +21,6 @@ use strict; > use warnings; > use base qw(Exporter); > use utf8; >-use Carp qw( carp ); > use English qw{ -no_match_vars }; > use Business::ISBN; > use DateTime; >@@ -69,8 +68,10 @@ sub create_edi_order { > my $ean = $parameters->{ean}; > my $branchcode = $parameters->{branchcode}; > my $noingest = $parameters->{noingest}; >+ my $logger = Koha::Logger->get( { interface => 'edi' } ); >+ > if ( !$basketno || !$ean ) { >- carp 'create_edi_order called with no basketno or ean'; >+ $logger->error('create_edi_order called with no basketno or ean'); > return; > } > >@@ -84,7 +85,7 @@ sub create_edi_order { > )->all; > > if ( !@orderlines ) { >- carp "No orderlines for basket $basketno"; >+ $logger->warn("No orderlines for basket $basketno"); > return; > } > >@@ -111,7 +112,7 @@ sub create_edi_order { > } > > unless ($ean_obj) { >- carp "No matching EAN found for $ean"; >+ $logger->warn("No matching EAN found for $ean"); > return; > } > >diff --git a/t/db_dependent/Koha/EDI.t b/t/db_dependent/Koha/EDI.t >index 9f037bd0eb4..810c60bc062 100755 >--- a/t/db_dependent/Koha/EDI.t >+++ b/t/db_dependent/Koha/EDI.t >@@ -20,8 +20,8 @@ > use Modern::Perl; > use FindBin qw( $Bin ); > >-use Test::More tests => 3; >-use Test::Warn; >+use Test::NoWarnings; >+use Test::More tests => 4; > use Test::MockModule; > > use t::lib::Mocks; >@@ -817,7 +817,7 @@ subtest 'process_invoice' => sub { > }; > > subtest 'process_invoice_without_tax_rate' => sub { >- plan tests => 4; >+ plan tests => 3; > > $schema->storage->txn_begin; > >@@ -873,23 +873,14 @@ subtest 'process_invoice_without_tax_rate' => sub { > > # Process the invoice - this should not generate warnings about undefined tax rates > my $error; >- my $warnings = []; >- { >- local $SIG{__WARN__} = sub { push @$warnings, $_[0] }; >- eval { >- process_invoice($invoice_message); >- 1; >- } or do { >- $error = $@; >- }; >- } >- >+ eval { >+ process_invoice($invoice_message); >+ 1; >+ } or do { >+ $error = $@; >+ }; > ok( !$error, 'process_invoice completed without dying when no tax rate present' ); > >- # Check that no warnings about uninitialized values in multiplication were generated >- my $tax_warnings = grep { /Use of uninitialized value.*multiplication/ } @$warnings; >- is( $tax_warnings, 0, 'No warnings about uninitialized values in multiplication' ); >- > # Verify that orders with tax data exist (means processing completed) > my $orders = $schema->resultset('Aqorder')->search( > { >-- >2.50.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 40387
:
184379
|
184380
|
184381
|
184382
|
184414
|
184415
|
184416
|
184417
|
184539
|
184544
|
184545
|
184546
|
184547
|
184548