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:
parent
4e6bc5385c
commit
8bfb09b68b
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue