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