From 4bcaeee45e05ba357fc87764a0d383e3e5fc8bf3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 17 Oct 2023 18:06:27 +0000 Subject: [PATCH] Bug 34014: Unit test Signed-off-by: Lucas Gass Signed-off-by: Kelly McElligott Signed-off-by: Martin Renvoize --- t/db_dependent/Biblio.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 8cf358d4124..4f096f7fe1c 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 19; +use Test::More tests => 20; use Test::MockModule; use Test::Warn; use List::MoreUtils qw( uniq ); @@ -26,6 +26,7 @@ use MARC::Record; use t::lib::Mocks qw( mock_preference ); use t::lib::TestBuilder; +use Koha::ActionLogs; use Koha::Database; use Koha::Caches; use Koha::MarcSubfieldStructures; @@ -996,6 +997,31 @@ subtest 'GetFrameworkCode' => sub { }; +subtest 'ModBiblio on invalid record' => sub { + plan tests => 3; + + t::lib::Mocks::mock_preference( "CataloguingLog", 1 ); + + # We create a record with an onvalid control character in the MARC + my $record = MARC::Record->new(); + my $field = MARC::Field->new( '650', '', '', 'a' => '00aD000015937' ); + $record->append_fields($field); + + my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' ); + + warning_like { C4::Biblio::ModBiblio( $record, $biblionumber, '' ); } + qr/parser error : PCDATA invalid Char value 31/, + 'Modding the biblio warns about the encoding issues'; + my $action_logs = + Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } ); + is( $action_logs->count, 1, "Modification of biblio was successful and recorded" ); + my $action_log = $action_logs->next; + like( + $action_log->info, qr/parser error : PCDATA invalid Char value 31/, + "Metadata issue successfully logged in action logs" + ); +}; + # Cleanup Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; -- 2.41.0