View | Details | Raw Unified | Return to bug 19353
Collapse All | Expand All

(-)a/t/db_dependent/OAI/Server.t (-2 / +30 lines)
Lines 20-27 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::MockTime qw/set_fixed_time restore_time/;
21
use Test::MockTime qw/set_fixed_time restore_time/;
22
22
23
use Test::More tests => 30;
23
use Test::More tests => 31;
24
use DateTime;
24
use DateTime;
25
use File::Basename;
26
use File::Spec;
25
use Test::MockModule;
27
use Test::MockModule;
26
use Test::Warn;
28
use Test::Warn;
27
use XML::Simple;
29
use XML::Simple;
Lines 75-81 set_fixed_time(CORE::time()); Link Here
75
my $base_datetime = dt_from_string();
77
my $base_datetime = dt_from_string();
76
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z';
78
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z';
77
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
79
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
78
my (@header, @marcxml, @oaidc);
80
my (@header, @marcxml, @oaidc, @marcxml_transformed);
79
my $sth = $dbh->prepare('UPDATE biblioitems     SET timestamp=? WHERE biblionumber=?');
81
my $sth = $dbh->prepare('UPDATE biblioitems     SET timestamp=? WHERE biblionumber=?');
80
my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?');
82
my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?');
81
83
Lines 85-93 foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { Link Here
85
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
87
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
86
        $record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) );
88
        $record->append_fields( MARC::Field->new('101', '', '', 'a' => "lng" ) );
87
        $record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) );
89
        $record->append_fields( MARC::Field->new('200', '', '', 'a' => "Title $index" ) );
90
        $record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) );
88
    } else {
91
    } else {
89
        $record->append_fields( MARC::Field->new('008', '                                   lng' ) );
92
        $record->append_fields( MARC::Field->new('008', '                                   lng' ) );
90
        $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) );
93
        $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) );
94
        $record->append_fields( MARC::Field->new('995', '', '', 'a' => "Code" ) );
91
    }
95
    }
92
    my ($biblionumber) = AddBiblio($record, '');
96
    my ($biblionumber) = AddBiblio($record, '');
93
    my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms;
97
    my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms;
Lines 96-101 foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { Link Here
96
    $timestamp .= 'Z';
100
    $timestamp .= 'Z';
97
    $timestamp =~ s/ /T/;
101
    $timestamp =~ s/ /T/;
98
    $record = GetMarcBiblio({ biblionumber => $biblionumber });
102
    $record = GetMarcBiblio({ biblionumber => $biblionumber });
103
    my $record_transformed = $record->clone;
104
    $record_transformed->delete_fields( $record_transformed->field('995'));
105
    $record_transformed = XMLin($record_transformed->as_xml_record);
99
    $record = XMLin($record->as_xml_record);
106
    $record = XMLin($record->as_xml_record);
100
    push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" };
107
    push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" };
101
    my $dc = {
108
    my $dc = {
Lines 122-127 foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { Link Here
122
            record => $record,
129
            record => $record,
123
        },
130
        },
124
    };
131
    };
132
133
    push @marcxml_transformed, {
134
        header => $header[$index],
135
        metadata => {
136
            record => $record_transformed,
137
        },
138
    };
125
}
139
}
126
140
127
my $syspref = {
141
my $syspref = {
Lines 348-353 test_query( Link Here
348
    },
362
    },
349
});
363
});
350
364
365
#  List records, but now transformed by XSLT
366
t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" =>  File::Spec->rel2abs(dirname(__FILE__)) . "/oaiconf.yaml");
367
test_query('ListRecords marcxml with xsl transformation',
368
    { verb => 'ListRecords', metadataPrefix => 'marcxml' },
369
    { ListRecords => {
370
        record => [ @marcxml_transformed[0..2] ],
371
        resumptionToken => {
372
            content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0",
373
            cursor => 3,
374
        }
375
    },
376
});
377
t::lib::Mocks::mock_preference("OAI-PMH:ConfFile" => undef);
378
351
restore_time();
379
restore_time();
352
380
353
subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub {
381
subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub {
(-)a/t/db_dependent/OAI/oaiconf.yaml (-1 / +7 lines)
Line 0 Link Here
0
- 
1
format:
2
    marcxml:
3
      metadataPrefix: marxml
4
      metadataNamespace: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim
5
      schema: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd
6
      xsl_file: /usr/share/koha/intranet/htdocs/intranet-tmpl/prog/en/xslt/Del995.xsl
7
      include_items: 0

Return to bug 19353