From ce2d689d7f98b7db8ef8289048813d647f5f9373 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Šťastný --- 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 de6939f2f7..bab84d146e 100755 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -20,8 +20,10 @@ use Modern::Perl; use Test::MockTime qw/set_fixed_time restore_time/; -use Test::More tests => 30; +use Test::More tests => 31; use DateTime; +use File::Basename; +use File::Spec; use Test::MockModule; use Test::Warn; use XML::Simple; @@ -75,7 +77,7 @@ set_fixed_time(CORE::time()); my $base_datetime = dt_from_string(); my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . '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('UPDATE biblioitems SET timestamp=? WHERE biblionumber=?'); my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?'); @@ -85,9 +87,11 @@ 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, ''); my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms; @@ -96,6 +100,9 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { $timestamp .= '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 = { @@ -122,6 +129,13 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { record => $record, }, }; + + push @marcxml_transformed, { + header => $header[$index], + metadata => { + record => $record_transformed, + }, + }; } my $syspref = { @@ -348,6 +362,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); + restore_time(); subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { diff --git a/t/db_dependent/OAI/oaiconf.yaml b/t/db_dependent/OAI/oaiconf.yaml new file mode 100644 index 0000000000..6d77f82608 --- /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.11.0