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

(-)a/t/db_dependent/OAI/Server.t (-28 / +26 lines)
Lines 56-66 my $schema = Koha::Database->schema; Link Here
56
$schema->storage->txn_begin;
56
$schema->storage->txn_begin;
57
my $dbh = C4::Context->dbh;
57
my $dbh = C4::Context->dbh;
58
58
59
$dbh->do('SET FOREIGN_KEY_CHECKS = 0');
60
$dbh->do("SET time_zone='+00:00'");
59
$dbh->do("SET time_zone='+00:00'");
61
$dbh->do('TRUNCATE biblio');
60
$dbh->do('DELETE FROM biblio');
62
$dbh->do('TRUNCATE biblioitems');
61
$dbh->do('DELETE FROM deletedbiblio');
63
$dbh->do('TRUNCATE issues');
62
$dbh->do('DELETE FROM deletedbiblioitems');
63
$dbh->do('DELETE FROM deleteditems');
64
64
65
my $date_added = DateTime->now() . 'Z';
65
my $date_added = DateTime->now() . 'Z';
66
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
66
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
Lines 68-91 my (@header, @marcxml, @oaidc); Link Here
68
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?');
68
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?');
69
69
70
# Add 10 biblio records
70
# Add 10 biblio records
71
foreach( 1..10 ) {
71
foreach my $index ( 0..9 ) {
72
    my $record = MARC::Record->new();
72
    my $record = MARC::Record->new();
73
    $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $_" ) );
73
    $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) );
74
    my ($biblionumber) = AddBiblio($record, '');
74
    my ($biblionumber) = AddBiblio($record, '');
75
    $sth->execute($biblionumber);
75
    $sth->execute($biblionumber);
76
    my $timestamp = $sth->fetchrow_array . 'Z';
76
    my $timestamp = $sth->fetchrow_array . 'Z';
77
    $timestamp =~ s/ /T/;
77
    $timestamp =~ s/ /T/;
78
    $record = GetMarcBiblio($biblionumber);
78
    $record = GetMarcBiblio($biblionumber);
79
    $record = XMLin($record->as_xml_record);
79
    $record = XMLin($record->as_xml_record);
80
    $header[$biblionumber] = { datestamp => $timestamp, identifier => "TEST:$biblionumber" };
80
    push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" };
81
    delete $record->{$_} for (('xmlns','xmlns:xsi','xsi:schemaLocation'));
81
    delete $record->{$_} for (('xmlns','xmlns:xsi','xsi:schemaLocation'));
82
    $oaidc[$biblionumber] = {
82
    push @oaidc, {
83
        header => $header[$biblionumber],
83
        header => $header[$index],
84
        metadata => {
84
        metadata => {
85
            'oai_dc:dcCollection' => {
85
            'oai_dc:dcCollection' => {
86
                'oai_dc:dc' => {
86
                'oai_dc:dc' => {
87
                    'dc:title' => {
87
                    'dc:title' => {
88
                        'content' => "Title $biblionumber",
88
                        'content' => "Title $index",
89
                        'xmlns:dc' => 'http://purl.org/dc/elements/1.1/'
89
                        'xmlns:dc' => 'http://purl.org/dc/elements/1.1/'
90
                    },
90
                    },
91
                    'dc:language' => {
91
                    'dc:language' => {
Lines 101-111 foreach( 1..10 ) { Link Here
101
            },
101
            },
102
        },
102
        },
103
    };
103
    };
104
    $marcxml[$biblionumber] = {
104
    push @marcxml, {
105
        header => $header[$biblionumber],
105
        header => $header[$index],
106
        metadata => {
106
        metadata => {
107
            collection => {
107
            collection => {
108
            record => $record,
108
                record => $record,
109
                "xmlns" => "http://www.loc.gov/MARC21/slim",
109
                "xmlns" => "http://www.loc.gov/MARC21/slim",
110
                "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
110
                "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
111
                "xsi:schemaLocation" => "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd",
111
                "xsi:schemaLocation" => "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd",
Lines 188-197 test_query('ListIdentifiers without metadataPrefix', {verb => 'ListIdentifiers'} Link Here
188
    },
188
    },
189
});
189
});
190
190
191
192
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'marcxml'}, {
191
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'marcxml'}, {
193
    ListIdentifiers => {
192
    ListIdentifiers => {
194
        header => [ @header[1..3] ],
193
        header => [ @header[0..2] ],
195
        resumptionToken => {
194
        resumptionToken => {
196
            content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
195
            content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
197
            cursor  => 3,
196
            cursor  => 3,
Lines 201-207 test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar Link Here
201
200
202
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'marcxml'}, {
201
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'marcxml'}, {
203
    ListIdentifiers => {
202
    ListIdentifiers => {
204
        header => [ @header[1..3] ],
203
        header => [ @header[0..2] ],
205
        resumptionToken => {
204
        resumptionToken => {
206
            content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
205
            content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
207
            cursor  => 3,
206
            cursor  => 3,
Lines 214-220 test_query( Link Here
214
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" },
213
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" },
215
    {
214
    {
216
        ListIdentifiers => {
215
        ListIdentifiers => {
217
            header => [ @header[4..6] ],
216
            header => [ @header[3..5] ],
218
            resumptionToken => {
217
            resumptionToken => {
219
              content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0",
218
              content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0",
220
              cursor  => 6,
219
              cursor  => 6,
Lines 229-235 test_query( Link Here
229
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" },
228
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" },
230
    {
229
    {
231
        ListIdentifiers => {
230
        ListIdentifiers => {
232
            header => [ @header[7..9] ],
231
            header => [ @header[6..8] ],
233
            resumptionToken => {
232
            resumptionToken => {
234
              content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0",
233
              content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0",
235
              cursor  => 9,
234
              cursor  => 9,
Lines 244-250 test_query( Link Here
244
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" },
243
    { verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" },
245
    {
244
    {
246
        ListIdentifiers => {
245
        ListIdentifiers => {
247
            header => $header[10],
246
            header => $header[9],
248
          },
247
          },
249
248
250
    },
249
    },
Lines 259-265 test_query('ListRecords marcxml without metadataPrefix', {verb => 'ListRecords'} Link Here
259
258
260
test_query('ListRecords marcxml', {verb => 'ListRecords', metadataPrefix => 'marcxml'}, {
259
test_query('ListRecords marcxml', {verb => 'ListRecords', metadataPrefix => 'marcxml'}, {
261
    ListRecords => {
260
    ListRecords => {
262
        record => [ @marcxml[1..3] ],
261
        record => [ @marcxml[0..2] ],
263
        resumptionToken => {
262
        resumptionToken => {
264
          content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
263
          content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0",
265
          cursor  => 3,
264
          cursor  => 3,
Lines 271-277 test_query( Link Here
271
    'ListRecords marcxml with resumptionToken 1',
270
    'ListRecords marcxml with resumptionToken 1',
272
    { verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" },
271
    { verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" },
273
    { ListRecords => {
272
    { ListRecords => {
274
        record => [ @marcxml[4..6] ],
273
        record => [ @marcxml[3..5] ],
275
        resumptionToken => {
274
        resumptionToken => {
276
          content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0",
275
          content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0",
277
          cursor  => 6,
276
          cursor  => 6,
Lines 283-289 test_query( Link Here
283
    'ListRecords marcxml with resumptionToken 2',
282
    'ListRecords marcxml with resumptionToken 2',
284
    { verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" },
283
    { verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" },
285
    { ListRecords => {
284
    { ListRecords => {
286
        record => [ @marcxml[7..9] ],
285
        record => [ @marcxml[6..8] ],
287
        resumptionToken => {
286
        resumptionToken => {
288
          content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0",
287
          content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0",
289
          cursor  => 9,
288
          cursor  => 9,
Lines 296-308 test_query( Link Here
296
    'ListRecords marcxml with resumptionToken 3, response without resumption',
295
    'ListRecords marcxml with resumptionToken 3, response without resumption',
297
    { verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" },
296
    { verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" },
298
    { ListRecords => {
297
    { ListRecords => {
299
        record => $marcxml[10],
298
        record => $marcxml[9],
300
    },
299
    },
301
});
300
});
302
301
303
test_query('ListRecords oai_dc', {verb => 'ListRecords', metadataPrefix => 'oai_dc'}, {
302
test_query('ListRecords oai_dc', {verb => 'ListRecords', metadataPrefix => 'oai_dc'}, {
304
    ListRecords => {
303
    ListRecords => {
305
        record => [ @oaidc[1..3] ],
304
        record => [ @oaidc[0..2] ],
306
        resumptionToken => {
305
        resumptionToken => {
307
          content => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0",
306
          content => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0",
308
          cursor  => 3,
307
          cursor  => 3,
Lines 314-320 test_query( Link Here
314
    'ListRecords oai_dc with resumptionToken 1',
313
    'ListRecords oai_dc with resumptionToken 1',
315
    { verb => 'ListRecords', resumptionToken => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0" },
314
    { verb => 'ListRecords', resumptionToken => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0" },
316
    { ListRecords => {
315
    { ListRecords => {
317
        record => [ @oaidc[4..6] ],
316
        record => [ @oaidc[3..5] ],
318
        resumptionToken => {
317
        resumptionToken => {
319
          content => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0",
318
          content => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0",
320
          cursor  => 6,
319
          cursor  => 6,
Lines 326-332 test_query( Link Here
326
    'ListRecords oai_dc with resumptionToken 2',
325
    'ListRecords oai_dc with resumptionToken 2',
327
    { verb => 'ListRecords', resumptionToken => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0" },
326
    { verb => 'ListRecords', resumptionToken => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0" },
328
    { ListRecords => {
327
    { ListRecords => {
329
        record => [ @oaidc[7..9] ],
328
        record => [ @oaidc[6..8] ],
330
        resumptionToken => {
329
        resumptionToken => {
331
          content => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0",
330
          content => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0",
332
          cursor  => 9,
331
          cursor  => 9,
Lines 339-345 test_query( Link Here
339
    'ListRecords oai_dc with resumptionToken 3, response without resumption',
338
    'ListRecords oai_dc with resumptionToken 3, response without resumption',
340
    { verb => 'ListRecords', resumptionToken => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0" },
339
    { verb => 'ListRecords', resumptionToken => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0" },
341
    { ListRecords => {
340
    { ListRecords => {
342
        record => $oaidc[10],
341
        record => $oaidc[9],
343
    },
342
    },
344
});
343
});
345
344
346
- 

Return to bug 15108