Bug 26886: Correct style of alert-error class in the OPAC
[koha.git] / C4 / SIP / t / 03checkout.t
blobc60bb0dbcc678cf42a8cca3202bf4e9389e72eca
1 #!/usr/bin/perl
2 # checkout: test Checkout Response
4 use strict;
5 use warnings;
6 use FindBin qw($Bin);
7 use lib "$Bin";
8 use Clone qw(clone);
10 use CGI qw ( -utf8 );
12 use C4::SIP::Sip::Constants qw(:all);
13 use SIPtest qw(
14 :basic
15 $user_barcode
16 :diacritic
17 :item1
20 my $patron_enable_template = {
21 id => 'Renew All: prep: enable patron permissions',
22 msg => "2520060102 084238AO$instid|AA$user_barcode|",
23 pat => qr/^26 {4}[ Y]{10}000$datepat/o,
24 fields => [],
27 my $patron_disable_template = {
28 id => 'Checkout: block patron (prep to test checkout denied)',
29 msg => "01N20060102 084238AO$instid|ALFees overrun|AA$user_barcode|",
30 # response to block patron is a patron status message
31 pat => qr/^24Y{4}[ Y]{10}000$datepat/o,
32 fields => [],
35 my $checkin_template = {
36 id => 'Checkout: cleanup: check in item',
37 msg => "09N20050102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|ACterminal password|",
38 pat => qr/^101YNN$datepat/o,
39 fields => [],
42 my $checkout_test_template = {
43 id => 'Checkout: valid item, valid patron',
44 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item_barcode|AC|",
45 pat => qr/^121NNY$datepat/,
46 fields => [
47 $SIPtest::field_specs{(FID_INST_ID)},
48 $SIPtest::field_specs{(FID_SCREEN_MSG)},
49 $SIPtest::field_specs{(FID_PRINT_LINE)},
50 { field => FID_PATRON_ID,
51 pat => qr/^$user_barcode$/o,
52 required => 1, },
53 { field => FID_ITEM_ID,
54 pat => qr/^$item_barcode$/o,
55 required => 1, },
56 { field => FID_TITLE_ID,
57 pat => qr/^$item_title\s*$/o,
58 required => 1, },
59 { field => FID_DUE_DATE,
60 pat => $textpat,
61 required => 1, },
62 { field => FID_FEE_TYPE,
63 pat => qr/^\d{2}$/,
64 required => 0, },
65 { field => FID_SECURITY_INHIBIT,
66 pat => qr/^[YN]$/,
67 required => 0, },
68 { field => FID_CURRENCY,
69 pat => qr/^$currency$/o,
70 required => 0, },
71 { field => FID_FEE_AMT,
72 pat => qr/^[.0-9]+$/,
73 required => 0, },
74 { field => FID_MEDIA_TYPE,
75 pat => qr/^\d{3}$/,
76 required => 0, },
77 { field => FID_ITEM_PROPS,
78 pat => $textpat,
79 required => 0, },
80 { field => FID_TRANSACTION_ID,
81 pat => $textpat,
82 required => 0, },
83 ], };
85 my @tests = (
86 $SIPtest::login_test,
87 $SIPtest::sc_status_test,
88 clone($checkout_test_template),
89 # Don't check the item in, because we're about to test renew
92 my $test;
94 ## Renewal OK
95 ## Test this by checking out exactly the same book a second time.
96 ## The only difference should be that the "Renewal OK" flag should now
97 ## be 'Y'.
98 #$test = clone($checkout_test_template);
99 #$test->{id} = 'Checkout: patron renewal';
100 #$test->{pat} = qr/^121YNY$datepat/;
102 #push @tests, $test;
104 # NOW check it in
106 push @tests, $checkin_template;
108 # Valid Patron, item with diacritical in the title
109 #$test = clone($checkout_test_template);
111 #$test->{id} = 'Checkout: valid patron, diacritical character in title';
112 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
114 #foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
115 # my $field = $test->{fields}[$i];
117 # if ($field->{field} eq FID_ITEM_ID) {
118 # $field->{pat} = qr/^$item_diacritic_barcode$/;
119 # } elsif ($field->{field} eq FID_TITLE_ID) {
120 # $field->{pat} = qr/^$item_diacritic_title\s*$/;
121 # } elsif ($field->{field} eq FID_OWNER) {
122 # $field->{pat} = qr/^$item_diacritic_owner$/;
126 #push @tests, $test;
128 #$test = clone($checkin_template);
129 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
130 #push @tests, $test;
132 # Valid Patron, Invalid Item_id
133 $test = clone($checkout_test_template);
135 $test->{id} = 'Checkout: valid patron, invalid item';
136 $test->{msg} =~ s/AB$item_barcode/ABno-barcode/o;
137 $test->{pat} = qr/^120NUN$datepat/;
138 delete $test->{fields};
139 $test->{fields} = [
140 $SIPtest::field_specs{(FID_INST_ID)},
141 $SIPtest::field_specs{(FID_SCREEN_MSG)},
142 $SIPtest::field_specs{(FID_PRINT_LINE)},
143 { field => FID_PATRON_ID,
144 pat => qr/^$user_barcode$/o,
145 required => 1, },
146 { field => FID_ITEM_ID,
147 pat => qr/^no-barcode$/,
148 required => 1, },
149 { field => FID_TITLE_ID,
150 pat => qr/^$/,
151 required => 1, },
152 { field => FID_DUE_DATE,
153 pat => qr/^$/,
154 required => 1, },
155 { field => FID_VALID_PATRON,
156 pat => qr/^Y$/,
157 required => 1, },
160 push @tests, $test;
162 # Invalid patron, valid item
163 $test = clone($checkout_test_template);
164 $test->{id} = 'Checkout: invalid patron, valid item';
165 $test->{msg} =~ s/AA$user_barcode/AAberick/;
166 $test->{pat} = qr/^120NUN$datepat/;
167 delete $test->{fields};
168 $test->{fields} = [
169 $SIPtest::field_specs{(FID_INST_ID)},
170 $SIPtest::field_specs{(FID_SCREEN_MSG)},
171 $SIPtest::field_specs{(FID_PRINT_LINE)},
172 { field => FID_PATRON_ID,
173 pat => qr/^berick$/,
174 required => 1, },
175 { field => FID_ITEM_ID,
176 pat => qr/^$item_barcode$/o,
177 required => 1, },
178 { field => FID_TITLE_ID,
179 pat => qr/^$item_title\s*$/o,
180 required => 1, },
181 { field => FID_DUE_DATE,
182 pat => qr/^$/,
183 required => 1, },
184 { field => FID_VALID_PATRON,
185 pat => qr/^N$/,
186 required => 1, },
189 push @tests, $test;
191 # Needed: tests for blocked patrons, patrons with excessive
192 # fines/fees, magnetic media, charging fees to borrow items.
194 ## Blocked patron
195 #$test = clone($checkout_test_template);
196 #$test->{id} = 'Checkout: Blocked patron';
197 #$test->{pat} = qr/^120NUN$datepat/;
198 #delete $test->{fields};
199 #$test->{fields} = [
200 # $SIPtest::field_specs{(FID_INST_ID)},
201 # $SIPtest::field_specs{(FID_SCREEN_MSG)},
202 # $SIPtest::field_specs{(FID_PRINT_LINE)},
203 # { field => FID_PATRON_ID,
204 # pat => qr/^$user_barcode$/,
205 # required => 1, },
206 # { field => FID_VALID_PATRON,
207 # pat => qr/^Y$/,
208 # required => 1, },
209 # ];
211 #push @tests, $patron_disable_template, $test, $patron_enable_template;
213 SIPtest::run_sip_tests(@tests);