Bugzilla – Attachment 184382 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 tests for create_edi_order logger calls
Bug-40387-Add-tests-for-createediorder-logger-call.patch (text/plain), 3.71 KB, created by
Martin Renvoize (ashimema)
on 2025-07-18 13:48:26 UTC
(
hide
)
Description:
Bug 40387: Add tests for create_edi_order logger calls
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-18 13:48:26 UTC
Size:
3.71 KB
patch
obsolete
>From 380b5bf991a5be6e90bb4ab28dc6cde8ae9bfc38 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 18 Jul 2025 14:43:15 +0100 >Subject: [PATCH] Bug 40387: Add tests for create_edi_order logger calls > >Tests for the logger calls introduced in the create_edi_order >in the last commit. >--- > t/db_dependent/Koha/EDI.t | 81 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 79 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/EDI.t b/t/db_dependent/Koha/EDI.t >index 810c60bc062..46a876cfb71 100755 >--- a/t/db_dependent/Koha/EDI.t >+++ b/t/db_dependent/Koha/EDI.t >@@ -21,14 +21,14 @@ use Modern::Perl; > use FindBin qw( $Bin ); > > use Test::NoWarnings; >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::MockModule; > > use t::lib::Mocks; > use t::lib::Mocks::Logger; > use t::lib::TestBuilder; > >-use Koha::EDI qw(process_quote process_invoice); >+use Koha::EDI qw(process_quote process_invoice create_edi_order); > use Koha::Edifact::Transport; > use Koha::Edifact::File::Errors; > use Koha::DateUtils qw(dt_from_string); >@@ -897,3 +897,80 @@ subtest 'process_invoice_without_tax_rate' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'create_edi_order_logging' => sub { >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ # Test 1: Error when called without basketno >+ $logger->clear(); >+ my $result = create_edi_order( { ean => '1234567890' } ); >+ ok( !defined $result, 'create_edi_order returns undef when called without basketno' ); >+ $logger->error_is( >+ 'create_edi_order called with no basketno or ean', >+ 'Error logged when create_edi_order called without basketno' >+ ); >+ >+ # Test 2: Error when called without ean >+ $logger->clear(); >+ $result = create_edi_order( { basketno => 123 } ); >+ ok( !defined $result, 'create_edi_order returns undef when called without ean' ); >+ $logger->error_is( >+ 'create_edi_order called with no basketno or ean', >+ 'Error logged when create_edi_order called without ean' >+ ); >+ >+ # Test 3: Warning when no orderlines for basket >+ $logger->clear(); >+ my $empty_basket = $builder->build_object( { class => 'Koha::Acquisition::Baskets' } ); >+ my $ean = $builder->build( >+ { >+ source => 'EdifactEan', >+ value => { >+ description => 'test ean', >+ branchcode => undef, >+ ean => '1234567890' >+ } >+ } >+ ); >+ >+ $result = create_edi_order( >+ { >+ basketno => $empty_basket->basketno, >+ ean => $ean->{ean} >+ } >+ ); >+ ok( !defined $result, 'create_edi_order returns undef when no orderlines for basket' ); >+ $logger->warn_is( >+ "No orderlines for basket " . $empty_basket->basketno, >+ 'Warning logged when no orderlines for basket' >+ ); >+ >+ # Test 4: Warning when no matching EAN found >+ $logger->clear(); >+ my $basket_with_orders = $builder->build_object( { class => 'Koha::Acquisition::Baskets' } ); >+ my $order = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ basketno => $basket_with_orders->basketno, >+ orderstatus => 'new' >+ } >+ } >+ ); >+ >+ $result = create_edi_order( >+ { >+ basketno => $basket_with_orders->basketno, >+ ean => 'nonexistent_ean' >+ } >+ ); >+ ok( !defined $result, 'create_edi_order returns undef when no matching EAN found' ); >+ $logger->warn_is( >+ 'No matching EAN found for nonexistent_ean', >+ 'Warning logged when no matching EAN found' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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