Translation updates for Koha 16.05 (beta) release
[koha.git] / C4 / SIP / t / 08checkin.t
blobd6165a2bb53deb5d1da8391ce14f8827dcf9920b
1 #!/usr/bin/perl
2 # checkin: test Checkin Response
4 use strict;
5 use warnings;
6 use FindBin qw($Bin);
7 use lib "$Bin";
8 use Clone qw(clone);
10 use C4::SIP::Sip::Constants qw(:all);
11 use SIPtest qw(:basic :user1 :item1);
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
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
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 => [],
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 ],};
61 my @tests = (
62 $SIPtest::login_test,
63 $SIPtest::sc_status_test,
64 $checkout_template,
65 $checkin_test_template,
68 my $test;
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}}];
78 push @tests, $test;
81 # Still need tests for magnetic media
84 SIPtest::run_sip_tests(@tests);