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