From 96b8df9b0df22f15d7d32930e176d17f07b3701e Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Tue, 12 Mar 2019 13:46:14 +0000 Subject: [PATCH] Bug 8995: (follow-up) Added test Signed-off-by: Magnus Enger --- t/db_dependent/Biblio.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 60ccde3a18..bf37fac840 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use Test::MockModule; use List::MoreUtils qw( uniq ); use MARC::Record; @@ -573,3 +573,32 @@ subtest 'MarcFieldForCreatorAndModifier' => sub { # Cleanup Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; + +subtest 'GetCOinSBiblio and GetOpenURLResolverURL' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $builder = t::lib::TestBuilder->new; + my $biblio = $builder->build_sample_biblio({ + title => 'Title 1', + author => 'Author 1' + }); + my $record = $biblio->metadata->record; + + t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/"); + + is( + C4::Biblio::GetCOinSBiblio($record), + 'ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Title%201&rft.au=Author%201', + 'GetCOinsBiblio returned right metadata' + ); + + is( + C4::Biblio::GetOpenURLResolverURL($record), + 'https://koha.example.com/?ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Title%201&rft.au=Author%201', + 'GetOpenURLResolverURL returned right URL' + ); + + $schema->storage->txn_rollback; +}; -- 2.11.0