Bug 13937: Add unit tests
[koha.git] / t / Koha / Z3950responder.t
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4 use Test::More tests => 8;
5
6 BEGIN {
7     use_ok('Koha::Z3950Responder');
8 }
9
10 my $zR = Koha::Z3950Responder->new({});
11
12 my $args={ PEER_NAME => 'PEER'};
13 $zR->init_handler($args);
14 is ( $args->{IMP_NAME}, 'Koha',"Server returns basic info");
15 $args->{DATABASES} = ['biblios'];
16 $args->{QUERY} = 'biblios';
17 $args->{SETNAME} = 'biblios';
18 $args->{START} = 0;
19 $args->{OFFSET} = 0;
20 $args->{NUMBER} = 42;
21 $zR->search_handler( $args );
22 is ( $args->{ERR_CODE}, 2, "We didn't start server , should fail");
23 is ( $args->{ERR_STR}, 'Cannot connect to upstream server', "We didn't start server, should fail because it cannot connect");
24 $zR->present_handler( $args );
25 is ( $args->{ERR_CODE}, 30, "There is no handler as we aren't connected");
26 is ( $args->{ERR_STR}, 'No such resultset', "We don't have a handler, should fail because we don't");
27 my $arg_check = ( $args );
28 $zR->fetch_handler( $args );
29 is_deeply( $args, $arg_check, "nothing should change");
30 $zR->close_handler( $args );
31 is_deeply( $args, $arg_check, "nothing should change");