From 04398df3726febe830519418014ca0dbc1ba967f Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 1 Dec 2017 15:18:04 +0000 Subject: [PATCH] Bug 19725: Add failing test Also fix tests for UNIMARC Test plan: 1. prove t/db_dependent/OAI/Server.t 2. Verify that it FAILS Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens (cherry picked from commit 55824b09d63ee83a8358c6e6f7740f664d3b86e3) Signed-off-by: Fridolin Somers --- t/db_dependent/OAI/Server.t | 48 +++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index 97d2c8d6f9..67805c3be3 100644 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 28; +use Test::More tests => 29; use DateTime; use Test::MockModule; use Test::Warn; @@ -89,18 +89,22 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { $record = GetMarcBiblio($biblionumber); $record = XMLin($record->as_xml_record); push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; + my $dc = { + 'dc:title' => "Title $index", + 'dc:language' => "lng", + 'dc:type' => {}, + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/', + 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', + 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd', + }; + if (C4::Context->preference('marcflavour') eq 'UNIMARC') { + $dc->{'dc:identifier'} = $biblionumber; + } push @oaidc, { header => $header[$index], metadata => { - 'oai_dc:dc' => { - 'dc:title' => "Title $index", - 'dc:language' => "lng", - 'dc:type' => {}, - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/', - 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', - 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd', - }, + 'oai_dc:dc' => $dc, }, }; push @marcxml, { @@ -335,6 +339,30 @@ test_query( }, }); +subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { + plan tests => 1; + + # Wait 1 second to be sure no timestamp will be equal to $from defined below + sleep 1; + + my $from_dt = DateTime->now; + my $from = $from_dt->ymd . 'T' . $from_dt->hms . 'Z'; + + # Modify record to trigger auto update of timestamp + (my $biblionumber = $marcxml[0]->{header}->{identifier}) =~ s/^.*:(.*)/$1/; + my $record = GetMarcBiblio($biblionumber); + $record->append_fields(MARC::Field->new(999, '', '', z => '_')); + ModBiblio($record, $biblionumber); + + test_query( + 'ListRecords oai_dc with parameter from', + { verb => 'ListRecords', metadataPrefix => 'oai_dc', from => $from }, + { ListRecords => { + record => $oaidc[0], + }, + }); +}; + $schema->storage->txn_rollback; sub manipulate_timestamp { -- 2.39.5