Bug 28604: Regression tests

This patch introduces regression tests for the encoding issue with MiJ
output.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit fc1e15029f)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 083f1133d5)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
(cherry picked from commit 541f85701f)
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit 541f85701f)
This commit is contained in:
Tomas Cohen Arazi 2021-06-18 18:30:56 -03:00 committed by Wainui Witika-Park
parent 03338f14b2
commit c1a76b0d80
1 changed files with 49 additions and 2 deletions

View File

@ -17,6 +17,9 @@
use Modern::Perl;
use utf8;
use Encode;
use Test::More tests => 3;
use Test::MockModule;
use Test::Mojo;
@ -38,7 +41,7 @@ my $t = Test::Mojo->new('Koha::REST::V1');
subtest 'get() tests' => sub {
plan tests => 21;
plan tests => 22;
$schema->storage->txn_begin;
@ -100,6 +103,28 @@ subtest 'get() tests' => sub {
->status_is(404)
->json_is( '/error', 'Object not found.' );
subtest 'marc-in-json encoding tests' => sub {
plan tests => 3;
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 $result = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber
=> { Accept => 'application/marc-in-json' } )
->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" );
};
$schema->storage->txn_rollback;
};
@ -157,7 +182,7 @@ subtest 'delete() tests' => sub {
subtest 'get_public() tests' => sub {
plan tests => 25;
plan tests => 26;
$schema->storage->txn_begin;
@ -240,6 +265,28 @@ subtest 'get_public() tests' => sub {
->content_is($biblio->metadata->record->as_formatted);
};
subtest 'marc-in-json encoding tests' => sub {
plan tests => 3;
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 $result = $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber
=> { Accept => 'application/marc-in-json' } )
->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" );
};
# Hide author in OPAC
$subfields = Koha::MarcSubfieldStructures->search({ tagfield => '100' });
while ( my $subfield = $subfields->next ) {