Bug 32336: Add unit test for UNIMARC encoding problems in REST API

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Julian Maurice 2023-01-20 15:33:39 +01:00 committed by Tomas Cohen Arazi
parent 4e6bc5385c
commit 8bfb09b68b
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 32 additions and 1 deletions

View File

@ -45,7 +45,7 @@ my $t = Test::Mojo->new('Koha::REST::V1');
subtest 'get() tests' => sub {
plan tests => 21;
plan tests => 22;
$schema->storage->txn_begin;
@ -124,6 +124,37 @@ subtest 'get() tests' => sub {
like( $result, qr/\Q$encoded_title/, "The title is not double encoded" );
};
subtest 'marcxml encoding tests' => sub {
plan tests => 3;
my $marcflavour = C4::Context->preference('marcflavour');
t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
my $title_with_diacritics = "L'insoutenable légèreté de l'être";
my $biblio = $builder->build_sample_biblio(
{
title => $title_with_diacritics,
author => "Milan Kundera"
}
);
my $record = $biblio->metadata->record;
$record->leader(' nam 3 4500');
$biblio->metadata->metadata($record->as_xml_record('UNIMARC'));
$biblio->metadata->store;
my $result = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber
=> { Accept => 'application/marcxml+xml' } )
->status_is(200)->tx->res->body;
my $encoded_title = Encode::encode( "UTF-8", $title_with_diacritics );
like( $result, qr/\Q$encoded_title/, "The title is not double encoded" );
t::lib::Mocks::mock_preference('marcflavour', $marcflavour);
};
$schema->storage->txn_rollback;
};