Lines 19-26
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 28; |
22 |
use Test::More tests => 29; |
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 68-74
$dbh->do('DELETE FROM oai_sets');
Link Here
|
68 |
|
70 |
|
69 |
my $date_added = DateTime->now() . 'Z'; |
71 |
my $date_added = DateTime->now() . 'Z'; |
70 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
72 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
71 |
my (@header, @marcxml, @oaidc); |
73 |
my (@header, @marcxml, @oaidc, @marcxml_transformed); |
72 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
74 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
73 |
|
75 |
|
74 |
# Add biblio records |
76 |
# Add biblio records |
Lines 77-85
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
77 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
79 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
78 |
$record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) ); |
80 |
$record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) ); |
79 |
$record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) ); |
81 |
$record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) ); |
|
|
82 |
$record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); |
80 |
} else { |
83 |
} else { |
81 |
$record->append_fields( MARC::Field->new('008', ' lng' ) ); |
84 |
$record->append_fields( MARC::Field->new('008', ' lng' ) ); |
82 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
85 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
|
|
86 |
$record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) ); |
83 |
} |
87 |
} |
84 |
my ($biblionumber) = AddBiblio($record, ''); |
88 |
my ($biblionumber) = AddBiblio($record, ''); |
85 |
$sth->execute($biblionumber); |
89 |
$sth->execute($biblionumber); |
Lines 87-92
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
87 |
$timestamp =~ s/ /T/; |
91 |
$timestamp =~ s/ /T/; |
88 |
$timestamp = manipulate_timestamp( $index, $biblionumber, $timestamp ); |
92 |
$timestamp = manipulate_timestamp( $index, $biblionumber, $timestamp ); |
89 |
$record = GetMarcBiblio({ biblionumber => $biblionumber }); |
93 |
$record = GetMarcBiblio({ biblionumber => $biblionumber }); |
|
|
94 |
my $record_transformed = $record->clone; |
95 |
$record_transformed->delete_fields( $record_transformed->field('995')); |
96 |
$record_transformed = XMLin($record_transformed->as_xml_record); |
90 |
$record = XMLin($record->as_xml_record); |
97 |
$record = XMLin($record->as_xml_record); |
91 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
98 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
92 |
push @oaidc, { |
99 |
push @oaidc, { |
Lines 109-114
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
109 |
record => $record, |
116 |
record => $record, |
110 |
}, |
117 |
}, |
111 |
}; |
118 |
}; |
|
|
119 |
|
120 |
push @marcxml_transformed, { |
121 |
header => $header[$index], |
122 |
metadata => { |
123 |
record => $record_transformed, |
124 |
}, |
125 |
}; |
112 |
} |
126 |
} |
113 |
|
127 |
|
114 |
my $syspref = { |
128 |
my $syspref = { |
Lines 335-340
test_query(
Link Here
|
335 |
}, |
349 |
}, |
336 |
}); |
350 |
}); |
337 |
|
351 |
|
|
|
352 |
# List records, but now transformed by XSLT |
353 |
t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => File::Spec->rel2abs(dirname(__FILE__)) . "/oaiconf.yaml"); |
354 |
test_query('ListRecords marcxml with xsl transformation', |
355 |
{ verb => 'ListRecords', metadataPrefix => 'marcxml' }, |
356 |
{ ListRecords => { |
357 |
record => [ @marcxml_transformed[0..2] ], |
358 |
resumptionToken => { |
359 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
360 |
cursor => 3, |
361 |
} |
362 |
}, |
363 |
}); |
364 |
|
338 |
$schema->storage->txn_rollback; |
365 |
$schema->storage->txn_rollback; |
339 |
|
366 |
|
340 |
sub manipulate_timestamp { |
367 |
sub manipulate_timestamp { |