Bug 16849: Move IsDebarred to Koha::Patron->is_debarred
[koha.git] / t / Ediordrsp.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use FindBin qw( $Bin );
5
6 use Test::More tests => 16;
7
8 BEGIN { use_ok('Koha::Edifact') }
9
10 my $filedir = "$Bin/edi_testfiles";
11
12 my @files = map { "$filedir/$_" }
13   ( 'ordrsp1.CEA', 'ordrsp2.CEA', 'ordrsp3.CEA', 'ordrsp4.CEA' );
14
15 my @responses;
16 for my $filename (@files) {
17
18     my $order_response = Koha::Edifact->new( { filename => $filename, } );
19
20     isa_ok( $order_response, 'Koha::Edifact' );
21     push @responses, $order_response;
22 }
23
24 # tests on file 1
25 # Order accepted with amendments
26 my $order_response = $responses[0];
27
28 my $msg       = $order_response->message_array();
29 my $no_of_msg = @{$msg};
30 is( $no_of_msg, 1, "Correct number of messages returned" );
31
32 isa_ok( $msg->[0], 'Koha::Edifact::Message' );
33
34 my $lines = $msg->[0]->lineitems();
35
36 my $no_of_lines = @{$lines};
37
38 is( $no_of_lines, 3, "Correct number of orderlines returned" );
39
40 #
41 is( $lines->[0]->ordernumber(), 'P28837', 'Line 1 correct ordernumber' );
42 is(
43     $lines->[0]->coded_orderline_text(),
44     'Not yet published',
45     'NP returned and translated'
46 );
47
48 is( $lines->[1]->ordernumber(), 'P28838', 'Line 2 correct ordernumber' );
49 is( $lines->[1]->action_notification(),
50     'cancelled', 'Cancelled action returned' );
51 is( $lines->[1]->coded_orderline_text(),
52     'Out of print', 'OP returned and translated' );
53
54 is( $lines->[2]->ordernumber(), 'P28846', 'Line 3 correct ordernumber' );
55 is( $lines->[2]->action_notification(),
56     'recorded', 'Accepted with change action returned' );
57
58 is( $lines->[0]->availability_date(), '19971120',
59     'Availability date returned' );