From 415236c5752fde409fbb84b49c2bf8ac16bb0885 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 4 Dec 2017 02:10:31 +0000 Subject: [PATCH] Bug 19353: Add test --- t/db_dependent/OAI/Server.t | 32 ++++++++++++++++++++++++++++++-- t/db_dependent/OAI/oaiconf.yaml | 7 +++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 t/db_dependent/OAI/oaiconf.yaml diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index 87d5c8b..aec1ad2 100644 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -19,8 +19,10 @@ use Modern::Perl; -use Test::More tests => 29; +use Test::More tests => 30; use DateTime; +use File::Basename; +use File::Spec; use Test::MockModule; use Test::Warn; use XML::Simple; @@ -71,7 +73,7 @@ $dbh->do('DELETE FROM oai_sets'); my $date_added = DateTime->now() . 'Z'; my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; -my (@header, @marcxml, @oaidc); +my (@header, @marcxml, @oaidc, @marcxml_transformed); my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); # Add biblio records @@ -80,15 +82,20 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { if (C4::Context->preference('marcflavour') eq 'UNIMARC') { $record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) ); $record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) ); + $record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); } else { $record->append_fields( MARC::Field->new('008', ' lng' ) ); $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); + $record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); } my ($biblionumber) = AddBiblio($record, ''); $sth->execute($biblionumber); my $timestamp = $sth->fetchrow_array . 'Z'; $timestamp =~ s/ /T/; $record = GetMarcBiblio({ biblionumber => $biblionumber }); + my $record_transformed = $record->clone; + $record_transformed->delete_fields( $record_transformed->field('995')); + $record_transformed = XMLin($record_transformed->as_xml_record); $record = XMLin($record->as_xml_record); push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; my $dc = { @@ -115,6 +122,13 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { record => $record, }, }; + + push @marcxml_transformed, { + header => $header[$index], + metadata => { + record => $record_transformed, + }, + }; } my $syspref = { @@ -341,6 +355,20 @@ test_query( }, }); +# List records, but now transformed by XSLT +t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => File::Spec->rel2abs(dirname(__FILE__)) . "/oaiconf.yaml"); +test_query('ListRecords marcxml with xsl transformation', + { verb => 'ListRecords', metadataPrefix => 'marcxml' }, + { ListRecords => { + record => [ @marcxml_transformed[0..2] ], + resumptionToken => { + content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", + cursor => 3, + } + }, +}); +t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => undef); + subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { plan tests => 1; diff --git a/t/db_dependent/OAI/oaiconf.yaml b/t/db_dependent/OAI/oaiconf.yaml new file mode 100644 index 0000000..6d77f82 --- /dev/null +++ b/t/db_dependent/OAI/oaiconf.yaml @@ -0,0 +1,7 @@ +format: + marcxml: + metadataPrefix: marxml + metadataNamespace: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim + schema: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd + xsl_file: /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/en/xslt/Del995.xsl + include_items: 0 -- 2.1.4