]> git.evergreen-ils.org Git - working/NCIPServer.git/blob - t/NCIP.t
Refactoring NCIP.pm slightly, dealing with namespaces more elegantly
[working/NCIPServer.git] / t / NCIP.t
1 #
2 #===============================================================================
3 #
4 #         FILE: NCIP.t
5 #
6 #  DESCRIPTION:
7 #
8 #        FILES: ---
9 #         BUGS: ---
10 #        NOTES: ---
11 #       AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz
12 # ORGANIZATION: Koha Development Team
13 #      VERSION: 1.0
14 #      CREATED: 18/09/13 09:59:01
15 #     REVISION: ---
16 #===============================================================================
17
18 use strict;
19 use warnings;
20 use File::Slurp;
21
22 use Test::More tests => 9;    # last test to print
23
24 use lib 'lib';
25
26 use_ok('NCIP');
27 ok( my $ncip = NCIP->new('t/config_sample'), 'Create new object' );
28
29 my $xml = <<'EOT';
30 <?xml version="1.0" encoding="UTF-8"?>
31 <ns1:NCIPMessage
32   ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd" xmlns:ns1="http://www.niso.org/2008/ncip">
33 </ns1:NCIPMessage>
34 EOT
35
36 ok( my $response = $ncip->process_request($xml), 'Process a request' );
37
38 my $xmlbad = <<'EOT';
39 <xml>
40 this is bad
41 <xml>
42 </xml>
43 EOT
44
45 # handle_initiation is called as part of the process_request, but best to test
46 # anyway
47 ok( !$ncip->handle_initiation($xmlbad), 'Bad xml' );
48 ok( $ncip->handle_initiation($xml),     'Good XML' );
49
50 my $lookupitem = read_file('t/sample_data/LookupItem.xml');
51
52 ok( $response = $ncip->process_request($lookupitem), 'Try looking up an item');
53 is ($response, 'LookupItem', 'We got lookupitem');
54
55 $lookupitem = read_file('t/sample_data/LookupItemWithExampleItemIdentifierType.xml');
56 ok( $response = $ncip->process_request($lookupitem), 'Try looking up an item, with agency');
57 is ($response, 'LookupItem', 'We got lookupitem with agency');