Bug 17469: Follow-up adding hold print notice
[koha.git] / C4 / SIP / t / 10renew_all.t
blob29672930f324a10dafc055480778c289d9a50226
1 #!/usr/bin/perl
2 # renew_all: test Renew All 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);
12 use SIPtest qw(:basic :user1 :item1 :item2);
14 my $enable_template = {
15 id => 'Renew All: prep: enable patron permissions',
16 msg => "2520060102 084238AO$instid|AA$user_barcode|",
17 pat => qr/^26 {4}[ Y]{10}000$datepat/,
18 fields => [],
21 # reset_checkin_templates will be used to reset the status of the items if needed
22 # If "make test" is used (all tests at once), after the tests 08 and 09, the item stays checked out and this raises an error here
23 # so we begin with a Checkin, awaiting for the minimal answer : ^10 (Checkin response)
24 # Both results (101 and 100, for OK and NON OK) must be accepted, because if we run this test alone, the item won't necessarily be checked out
25 # and the checkin attempt will then result in a "100" code, which is not a problem (we are just preparing the renewal tests)
26 my @reset_checkin_templates = (
28 id => "Renew All: prep: check in $item_barcode (used in previous tests)",
29 msg => "09N20060102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
30 pat => qr/^10/,
31 fields => [],
34 id => "Renew All: prep: check in $item2_barcode (used in previous tests)",
35 msg => "09N20060102 08423620060113 084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
36 pat => qr/^10/,
37 fields => [],
41 # Checkout as a preparation for renewal
42 my @checkout_templates = (
43 { id => "Renew All: prep: check out $item_barcode to $user_barcode",
44 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item_barcode|AC$password|",
45 pat => qr/^121NNY$datepat/,
46 fields => [],},
47 { id => "Renew All: prep: check out $item2_barcode to $user_barcode",
48 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item2_barcode|AC$password|",
49 pat => qr/^121NNY$datepat/,
50 fields => [],}
53 my $renew_all_test_template = {
54 id => "Renew All: patron ($user_barcode) with 1 item ($item_barcode) checked out, no patron password",
55 msg => "6520060102 084236AO$instid|AA$user_barcode|",
56 pat => qr/^66100010000$datepat/,
57 fields => [
58 $SIPtest::field_specs{(FID_INST_ID)},
59 $SIPtest::field_specs{(FID_SCREEN_MSG)},
60 $SIPtest::field_specs{(FID_PRINT_LINE)},
61 { field => FID_RENEWED_ITEMS,
62 pat => qr/^$item_barcode$/,
63 required => 1, },
67 # check the book in, when done testing
68 my @checkin_templates = (
70 id => "Renew All: prep: check in $item_barcode",
71 msg => "09N20060102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
72 pat => qr/^101YNN$datepat/,
73 fields => [],
76 id => "Renew All: prep: check in $item2_barcode",
77 msg => "09N20060102 08423620060113 084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
78 pat => qr/^101YNN$datepat/,
79 fields => [],
85 my @tests = (
86 $SIPtest::login_test,
87 $SIPtest::sc_status_test,
90 my $test;
92 # WIP?
93 $test = clone($renew_all_test_template);
94 $test->{id} = 'Renew All: Valid patron, two items checked out';
95 $test->{pat} = qr/^66100020000$datepat/;
96 foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
97 my $field = $test->{fields}[$i];
98 if ($field->{field} eq FID_RENEWED_ITEMS) {
99 $field->{pat} = qr/^$item_barcode\|$item2_barcode$/;
103 #push @tests, @checkout_templates[0..1], $renew_all_test_template, @checkin_templates[0..1];
105 $test = clone($renew_all_test_template);
106 $test->{id} = 'Renew All: valid patron, invalid patron password';
107 $test->{msg} .= (FID_PATRON_PWD) . 'bad_pwd|';
108 $test->{pat} = qr/^66000000000$datepat/;
109 delete $test->{fields};
110 $test->{fields} = [
111 $SIPtest::field_specs{(FID_INST_ID)},
112 $SIPtest::field_specs{(FID_SCREEN_MSG)},
113 $SIPtest::field_specs{(FID_PRINT_LINE)},
116 push @tests, $reset_checkin_templates[0], $checkout_templates[0], $test, $checkin_templates[0];
118 $test = clone($renew_all_test_template);
119 $test->{id} = 'Renew All: invalid patron';
120 $test->{msg} =~ s/AA$user_barcode/AAbad_barcode/;
121 $test->{pat} = qr/^66000000000$datepat/;
122 delete $test->{fields};
123 $test->{fields} = [
124 $SIPtest::field_specs{(FID_INST_ID)},
125 $SIPtest::field_specs{(FID_SCREEN_MSG)},
126 $SIPtest::field_specs{(FID_PRINT_LINE)},
128 push @tests, $test;
130 SIPtest::run_sip_tests(@tests);