Lines 47-52
BEGIN {
Link Here
|
47 |
use_ok('Koha::OAI::Server::ResumptionToken'); |
47 |
use_ok('Koha::OAI::Server::ResumptionToken'); |
48 |
} |
48 |
} |
49 |
|
49 |
|
|
|
50 |
use constant NUMBER_OF_MARC_RECORDS => 10; |
51 |
|
50 |
# Mocked CGI module in order to be able to send CGI parameters to OAI Server |
52 |
# Mocked CGI module in order to be able to send CGI parameters to OAI Server |
51 |
my %param; |
53 |
my %param; |
52 |
my $module = Test::MockModule->new('CGI'); |
54 |
my $module = Test::MockModule->new('CGI'); |
Lines 64-77
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
Link Here
|
64 |
my (@header, @marcxml, @oaidc); |
66 |
my (@header, @marcxml, @oaidc); |
65 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
67 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
66 |
|
68 |
|
67 |
# Add 10 biblio records |
69 |
# Add biblio records |
68 |
foreach my $index ( 0..9 ) { |
70 |
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { |
69 |
my $record = MARC::Record->new(); |
71 |
my $record = MARC::Record->new(); |
70 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
72 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); |
71 |
my ($biblionumber) = AddBiblio($record, ''); |
73 |
my ($biblionumber) = AddBiblio($record, ''); |
72 |
$sth->execute($biblionumber); |
74 |
$sth->execute($biblionumber); |
73 |
my $timestamp = $sth->fetchrow_array . 'Z'; |
75 |
my $timestamp = $sth->fetchrow_array . 'Z'; |
74 |
$timestamp =~ s/ /T/; |
76 |
$timestamp =~ s/ /T/; |
|
|
77 |
$timestamp = manipulate_timestamp( $index, $biblionumber, $timestamp ); |
75 |
$record = GetMarcBiblio($biblionumber); |
78 |
$record = GetMarcBiblio($biblionumber); |
76 |
$record = XMLin($record->as_xml_record); |
79 |
$record = XMLin($record->as_xml_record); |
77 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
80 |
push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
Lines 109-115
foreach my $index ( 0..9 ) {
Link Here
|
109 |
}, |
112 |
}, |
110 |
}, |
113 |
}, |
111 |
}; |
114 |
}; |
112 |
sleep 2; # FIXME Why do we need this sleep? |
|
|
113 |
} |
115 |
} |
114 |
|
116 |
|
115 |
my $syspref = { |
117 |
my $syspref = { |
Lines 340-342
test_query(
Link Here
|
340 |
}); |
342 |
}); |
341 |
|
343 |
|
342 |
$schema->storage->txn_rollback; |
344 |
$schema->storage->txn_rollback; |
343 |
- |
345 |
|
|
|
346 |
sub manipulate_timestamp { |
347 |
# This eliminates waiting a few seconds in order to get a higher timestamp |
348 |
my ( $index, $bibno, $timestamp ) = @_; |
349 |
my ( $year ) = $timestamp =~ /(\d{4})/; |
350 |
return $timestamp if !$year; # bad luck |
351 |
$year += $index - NUMBER_OF_MARC_RECORDS; |
352 |
$timestamp =~ s/\d{4}/$year/; |
353 |
$timestamp =~ s/02-29T/02-28T/; # paranoid programmer |
354 |
$dbh->do("UPDATE biblioitems SET timestamp=? WHERE biblionumber=?", undef, |
355 |
( $timestamp, $bibno )); |
356 |
return $timestamp; |
357 |
} |