Bugzilla – Attachment 188020 Details for
Bug 41036
Koha::ImportBatch is not logging errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41036: Add tests
Bug-41036-Add-tests.patch (text/plain), 2.81 KB, created by
Lari Taskula
on 2025-10-16 17:19:44 UTC
(
hide
)
Description:
Bug 41036: Add tests
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2025-10-16 17:19:44 UTC
Size:
2.81 KB
patch
obsolete
>From da5074a5453bfb5c0ebbb20a0b3a02e3b9ca35f2 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Thu, 16 Oct 2025 20:15:48 +0300 >Subject: [PATCH] Bug 41036: Add tests > >To test: >1. Apply only this patch, do not yet apply the next one >2. prove t/db_dependent/Koha/ImportBatch.t >3. Observe tests failing >--- > t/db_dependent/Koha/ImportBatch.t | 68 +++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > create mode 100644 t/db_dependent/Koha/ImportBatch.t > >diff --git a/t/db_dependent/Koha/ImportBatch.t b/t/db_dependent/Koha/ImportBatch.t >new file mode 100644 >index 00000000000..5fb7d519ad4 >--- /dev/null >+++ b/t/db_dependent/Koha/ImportBatch.t >@@ -0,0 +1,68 @@ >+#!/usr/bin/perl >+ >+# Copyright 2024 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <https://www.gnu.org/licenses> >+ >+use Modern::Perl; >+ >+use Test::MockModule; >+use Test::More tests => 2; >+ >+use t::lib::Mocks::Logger; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+my $logger = t::lib::Mocks::Logger->new; >+ >+use_ok('Koha::ImportBatch'); >+ >+subtest 'Koha::ImportBatch->new_from_file tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $mocked_c4_importbatch = Test::MockModule->new('C4::ImportBatch'); >+ $mocked_c4_importbatch->mock( >+ 'RecordsFromMARCXMLFile', >+ sub { >+ return ( [ "marcxml error 1", "error 2" ], [] ); >+ } >+ ); >+ >+ Koha::ImportBatch->new_from_file( { record_type => 'biblio', format => 'MARCXML', filepath => 'none' } ); >+ $logger->warn_is( >+ "The following error(s) occurred during MARCXML record import:\nERROR: marcxml error 1\nERROR: error 2", >+ "Errors are being logged" >+ ); >+ >+ $mocked_c4_importbatch->mock( >+ 'RecordsFromISO2709File', >+ sub { >+ return ( [ "iso2709 error 1", "error 2" ], [] ); >+ } >+ ); >+ >+ Koha::ImportBatch->new_from_file( { record_type => 'biblio', format => 'ISO2709', filepath => 'none' } ); >+ $logger->warn_is( >+ "The following error(s) occurred during ISO2709 record import:\nERROR: iso2709 error 1\nERROR: error 2", >+ "Errors are being logged" >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.34.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 41036
: 188020 |
188021