|
Lines 19-26
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 29; |
22 |
use Test::More tests => 30; |
| 23 |
use DateTime; |
23 |
use DateTime; |
|
|
24 |
use File::Basename; |
| 25 |
use File::Spec; |
| 24 |
use Test::MockModule; |
26 |
use Test::MockModule; |
| 25 |
use Test::Warn; |
27 |
use Test::Warn; |
| 26 |
use XML::Simple; |
28 |
use XML::Simple; |
|
Lines 71-77
$dbh->do('DELETE FROM oai_sets');
Link Here
|
| 71 |
|
73 |
|
| 72 |
my $date_added = DateTime->now() . 'Z'; |
74 |
my $date_added = DateTime->now() . 'Z'; |
| 73 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
75 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
| 74 |
my (@header, @marcxml, @oaidc); |
76 |
my (@header, @marcxml, @oaidc, @marcxml_transformed); |
| 75 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
77 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
| 76 |
|
78 |
|
| 77 |
# Add biblio records |
79 |
# Add biblio records |
|
Lines 80-94
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
| 80 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
82 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 81 |
$record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) ); |
83 |
$record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) ); |
| 82 |
$record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) ); |
84 |
$record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) ); |
|
|
85 |
$record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); |
| 83 |
} else { |
86 |
} else { |
| 84 |
$record->append_fields( MARC::Field->new('008', ' lng' ) ); |
87 |
$record->append_fields( MARC::Field->new('008', ' lng' ) ); |
| 85 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
88 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
|
|
89 |
$record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); |
| 86 |
} |
90 |
} |
| 87 |
my ($biblionumber) = AddBiblio($record, ''); |
91 |
my ($biblionumber) = AddBiblio($record, ''); |
| 88 |
$sth->execute($biblionumber); |
92 |
$sth->execute($biblionumber); |
| 89 |
my $timestamp = $sth->fetchrow_array . 'Z'; |
93 |
my $timestamp = $sth->fetchrow_array . 'Z'; |
| 90 |
$timestamp =~ s/ /T/; |
94 |
$timestamp =~ s/ /T/; |
| 91 |
$record = GetMarcBiblio({ biblionumber => $biblionumber }); |
95 |
$record = GetMarcBiblio({ biblionumber => $biblionumber }); |
|
|
96 |
my $record_transformed = $record->clone; |
| 97 |
$record_transformed->delete_fields( $record_transformed->field('995')); |
| 98 |
$record_transformed = XMLin($record_transformed->as_xml_record); |
| 92 |
$record = XMLin($record->as_xml_record); |
99 |
$record = XMLin($record->as_xml_record); |
| 93 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
100 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
| 94 |
my $dc = { |
101 |
my $dc = { |
|
Lines 115-120
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
| 115 |
record => $record, |
122 |
record => $record, |
| 116 |
}, |
123 |
}, |
| 117 |
}; |
124 |
}; |
|
|
125 |
|
| 126 |
push @marcxml_transformed, { |
| 127 |
header => $header[$index], |
| 128 |
metadata => { |
| 129 |
record => $record_transformed, |
| 130 |
}, |
| 131 |
}; |
| 118 |
} |
132 |
} |
| 119 |
|
133 |
|
| 120 |
my $syspref = { |
134 |
my $syspref = { |
|
Lines 341-346
test_query(
Link Here
|
| 341 |
}, |
355 |
}, |
| 342 |
}); |
356 |
}); |
| 343 |
|
357 |
|
|
|
358 |
# List records, but now transformed by XSLT |
| 359 |
t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => File::Spec->rel2abs(dirname(__FILE__)) . "/oaiconf.yaml"); |
| 360 |
test_query('ListRecords marcxml with xsl transformation', |
| 361 |
{ verb => 'ListRecords', metadataPrefix => 'marcxml' }, |
| 362 |
{ ListRecords => { |
| 363 |
record => [ @marcxml_transformed[0..2] ], |
| 364 |
resumptionToken => { |
| 365 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
| 366 |
cursor => 3, |
| 367 |
} |
| 368 |
}, |
| 369 |
}); |
| 370 |
t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => undef); |
| 371 |
|
| 344 |
subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { |
372 |
subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { |
| 345 |
plan tests => 1; |
373 |
plan tests => 1; |
| 346 |
|
374 |
|