Bug 12288: (follow-up) test for defined values
[koha.git] / C4 / SIP / t / 08checkin.t
1 #!/usr/bin/perl
2 # checkin: test Checkin Response
3
4 use strict;
5 use warnings;
6 use Clone qw(clone);
7
8 use Sip::Constants qw(:all);
9 use SIPtest qw(:basic :user1 :item1);
10
11 # Checkout response, format:
12 # code: 12
13 # success: 0 or 1
14 # renewal ok: Y or N
15 # magnetic media: Y, N or U
16 # desensitize: Y or N
17 # date
18
19 # Checkin response, format:
20 # code: 10
21 # success: 0 or 1
22 # resensitize: Y or N
23 # magnetic media: Y, N or U
24 # alert: Y or N
25 # date
26
27 my $checkout_template = {
28     id  => "Checkin: prep: check out item ($item_barcode)",
29     msg => "11YN20060329    203000                  AO$instid|AA$user_barcode|AB$item_barcode|AC|",
30     pat => qr/^121N[NYU][NY]$datepat/,
31     fields => [],
32 };
33
34 my $checkin_test_template = {
35     id  => "Checkin: Item ($item_barcode) is checked out",
36     msg => "09N20060102    08423620060113    084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
37     pat => qr/^101[NY][NYU]N$datepat/,
38     fields => [
39         $SIPtest::field_specs{(FID_INST_ID   )},
40         $SIPtest::field_specs{(FID_SCREEN_MSG)},
41         $SIPtest::field_specs{(FID_PRINT_LINE)},
42         { field    => FID_PATRON_ID,
43           pat      => qr/^$user_barcode$/,
44           required => 1, },
45         { field    => FID_ITEM_ID,
46           pat      => qr/^$item_barcode$/,
47           required => 1, },
48         { field    => FID_PERM_LOCN,
49           pat      => $textpat,
50           required => 1, },
51         { field    => FID_TITLE_ID,
52           pat      => qr/^$item_title\s*$/,
53           required => 1, }, # not required by the spec.
54         { field    => FID_DESTINATION_LOCATION,
55           pat      => qr/^$item_owner\s*$/,
56           required => 0, }, # 3M Extension
57    ],};
58
59 my @tests = (
60         $SIPtest::login_test,
61         $SIPtest::sc_status_test,
62         $checkout_template,
63         $checkin_test_template,
64         );
65
66 my $test;
67
68 # Checkin item that's not checked out.  Basically, this
69 # is identical to the first case, except the header says that
70 # the ILS didn't check the item in, and there's no patron id.
71 $test = clone($checkin_test_template);
72 $test->{id}  = 'Checkin: Item not checked out';
73 $test->{pat} = qr/^100[NY][NYU][NY]$datepat/o;
74 $test->{fields} = [grep $_->{field} ne FID_PATRON_ID, @{$test->{fields}}];
75
76 push @tests, $test;
77
78
79 # Still need tests for magnetic media
80
81
82 SIPtest::run_sip_tests(@tests);
83
84 1;