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

(-)a/t/db_dependent/OAI/Server.t (-19 / +12 lines)
Lines 17-35 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
21
use Modern::Perl;
20
use Modern::Perl;
22
use C4::Context;
21
23
use C4::Biblio;
24
use Test::More tests => 27;
22
use Test::More tests => 27;
23
use DateTime;
25
use Test::MockModule;
24
use Test::MockModule;
26
use Test::Warn;
25
use Test::Warn;
27
use DateTime;
28
use XML::Simple;
26
use XML::Simple;
29
use t::lib::Mocks;
30
use t::lib::TestBuilder;
31
use YAML;
27
use YAML;
32
28
29
use t::lib::Mocks;
30
31
use C4::Biblio;
32
use C4::Context;
33
use Koha::Database;
33
34
34
BEGIN {
35
BEGIN {
35
    use_ok('Koha::OAI::Server::DeletedRecord');
36
    use_ok('Koha::OAI::Server::DeletedRecord');
Lines 45-74 BEGIN { Link Here
45
    use_ok('Koha::OAI::Server::ResumptionToken');
46
    use_ok('Koha::OAI::Server::ResumptionToken');
46
}
47
}
47
48
48
49
# Mocked CGI module in order to be able to send CGI parameters to OAI Server
49
# Mocked CGI module in order to be able to send CGI parameters to OAI Server
50
my %param;
50
my %param;
51
my $module = Test::MockModule->new('CGI');
51
my $module = Test::MockModule->new('CGI');
52
    $module->mock('Vars', sub { %param; });
52
$module->mock('Vars', sub { %param; });
53
53
54
my $schema = Koha::Database->schema;
54
my $schema = Koha::Database->schema;
55
$schema->storage->txn_begin;
55
$schema->storage->txn_begin;
56
my $dbh = C4::Context->dbh;
56
my $dbh = C4::Context->dbh;
57
57
58
my $builder = t::lib::TestBuilder->new;
59
60
$dbh->do('SET FOREIGN_KEY_CHECKS = 0');
58
$dbh->do('SET FOREIGN_KEY_CHECKS = 0');
61
$dbh->do('TRUNCATE biblio');
59
$dbh->do('TRUNCATE biblio');
62
$dbh->do('TRUNCATE biblioitems');
60
$dbh->do('TRUNCATE biblioitems');
63
$dbh->do('TRUNCATE issues');
61
$dbh->do('TRUNCATE issues');
64
62
65
# Add 10 biblio records
66
our $tz = DateTime::TimeZone->new( name => 'local' );
63
our $tz = DateTime::TimeZone->new( name => 'local' );
67
my $date_added = DateTime->now(time_zone =>$tz) . 'Z';
64
my $date_added = DateTime->now(time_zone =>$tz) . 'Z';
68
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
65
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z';
69
70
my (@header, @marcxml, @oaidc);
66
my (@header, @marcxml, @oaidc);
71
map {
67
68
# Add 10 biblio records
69
foreach( 1..10 ) {
72
    my $record = MARC::Record->new();
70
    my $record = MARC::Record->new();
73
    $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $_" ) );
71
    $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $_" ) );
74
    my ($biblionumber) = AddBiblio($record, '');
72
    my ($biblionumber) = AddBiblio($record, '');
Lines 109-117 map { Link Here
109
            },
107
            },
110
        },
108
        },
111
    };
109
    };
112
    $biblionumber => undef;
110
}
113
} (1..10);
114
115
111
116
my $syspref = {
112
my $syspref = {
117
    'LibraryName'           => 'My Library',
113
    'LibraryName'           => 'My Library',
Lines 125-131 while ( my ($name, $value) = each %$syspref ) { Link Here
125
    t::lib::Mocks::mock_preference( $name => $value );
121
    t::lib::Mocks::mock_preference( $name => $value );
126
}
122
}
127
123
128
129
sub test_query {
124
sub test_query {
130
    my ($test, $param, $expected) = @_;
125
    my ($test, $param, $expected) = @_;
131
126
Lines 158-164 sub test_query { Link Here
158
    }
153
    }
159
}
154
}
160
155
161
162
test_query('ListMetadataFormats', {verb => 'ListMetadataFormats'}, {
156
test_query('ListMetadataFormats', {verb => 'ListMetadataFormats'}, {
163
    ListMetadataFormats => {
157
    ListMetadataFormats => {
164
        metadataFormat => [
158
        metadataFormat => [
165
- 

Return to bug 17493