395cda5171cc86c384d6a5737ab61fcb6a26b2bf
[koha.git] / C4 / SIP / koha_test / 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
10 use SIPtest qw($datepat $textpat $instid $user_barcode
11                $item_barcode $item_title);
12
13 my $checkin_test_template = {
14     id => 'Checkin: Item is checked out',
15     msg => "09N20060102    08423620060113    084235APUnder the bed|AO$instid|AB$item_barcode|ACterminal password|",
16     pat => qr/^101YNN$datepat/o,
17     fields => [
18                $SIPtest::field_specs{(FID_INST_ID)},
19                $SIPtest::field_specs{(FID_SCREEN_MSG)},
20                $SIPtest::field_specs{(FID_PRINT_LINE)},
21                { field    => FID_PATRON_ID,
22                  pat      => qr/^$user_barcode$/o,
23                  required => 1, },
24                { field    => FID_ITEM_ID,
25                  pat      => qr/^$item_barcode$/o,
26                  required => 1, },
27                { field    => FID_PERM_LOCN,
28                  pat      => $textpat,
29                  required => 1, },
30                { field    => FID_TITLE_ID,
31                  pat      => qr/^$item_title\s*$/o,
32                  required => 1, }, # not required by the spec.
33                ],};
34
35 my $checkout_template = {
36     id => 'Checkin: prep: check out item',
37     msg => "11YN20060329    203000                  AO$instid|AA$user_barcode|AB$item_barcode|AC|",
38     pat => qr/^121NNY$datepat/o,
39     fields => [],
40 };
41
42 my @tests = (
43              $SIPtest::login_test,
44              $SIPtest::sc_status_test,
45              $checkout_template,
46              $checkin_test_template,
47              );
48
49 my $test;
50
51 # Checkin item that's not checked out.  Basically, this
52 # is identical to the first case, except the header says that
53 # the ILS didn't check the item in, and there's no patron id.
54 $test = clone($checkin_test_template);
55 $test->{id} = 'Checkin: Item not checked out';
56 $test->{pat} = qr/^100YNN$datepat/o;
57 $test->{fields} = [grep $_->{field} ne FID_PATRON_ID, @{$test->{fields}}];
58
59 push @tests, $test;
60
61
62 # Still need tests for magnetic media
63
64
65 SIPtest::run_sip_tests(@tests);
66
67 1;