4 use FindBin
qw( $Bin );
6 use Test::More tests => 16;
8 BEGIN { use_ok('Koha::Edifact') }
10 my $filedir = "$Bin/edi_testfiles";
12 my @files = map { "$filedir/$_" }
13 ( 'ordrsp1.CEA', 'ordrsp2.CEA', 'ordrsp3.CEA', 'ordrsp4.CEA' );
16 for my $filename (@files) {
18 my $order_response = Koha::Edifact->new( { filename => $filename, } );
20 isa_ok( $order_response, 'Koha::Edifact' );
21 push @responses, $order_response;
25 # Order accepted with amendments
26 my $order_response = $responses[0];
28 my $msg = $order_response->message_array();
29 my $no_of_msg = @{$msg};
30 is( $no_of_msg, 1, "Correct number of messages returned" );
32 isa_ok( $msg->[0], 'Koha::Edifact::Message' );
34 my $lines = $msg->[0]->lineitems();
36 my $no_of_lines = @{$lines};
38 is( $no_of_lines, 3, "Correct number of orderlines returned" );
41 is( $lines->[0]->ordernumber(), 'P28837', 'Line 1 correct ordernumber' );
43 $lines->[0]->coded_orderline_text(),
45 'NP returned and translated'
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' );
54 is( $lines->[2]->ordernumber(), 'P28846', 'Line 3 correct ordernumber' );
55 is( $lines->[2]->action_notification(),
56 'recorded', 'Accepted with change action returned' );
58 is( $lines->[0]->availability_date(), '19971120',
59 'Availability date returned' );