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

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

Return to bug 15108