4 use FindBin
qw( $Bin );
6 use Test::More tests => 6;
8 BEGIN { use_ok('Koha::Edifact::Order') }
11 # The following tests are for internal methods but they could
12 # error spectacularly so yest
13 # Check that quoting is done correctly
16 Koha::Edifact::Order::encode_text(q{string containing ?,',:,+});
19 $processed_text, 'eq',
20 q{string containing ??,?',?:,?+},
21 'Outgoing text correctly quoted'
24 # extend above test to test chunking in imd_segment
27 my $data_to_encode = $processed_text;
29 my @segs = Koha
::Edifact
::Order
::imd_segment
( $code, $data_to_encode );
31 my $testseg = "IMD+L+010+:::$processed_text";
32 $testseg .= q{'}; # add segment terminator
34 cmp_ok
( $segs[0], 'eq', $testseg, 'IMD segment correctly formed' );
36 $data_to_encode = 'A' x
35;
37 $data_to_encode .= 'B' x
35;
38 $data_to_encode .= 'C' x
10;
40 @segs = Koha
::Edifact
::Order
::imd_segment
( $code, $data_to_encode );
45 q{IMD+L+010+:::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'},
46 'IMD segment correctly chunked'
48 cmp_ok
( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC'},
49 'IMD segment correctly split across segments' );
51 $data_to_encode .= '??';
53 # this used to cause an infinite loop
54 @segs = Koha
::Edifact
::Order
::imd_segment
( $code, $data_to_encode );
55 cmp_ok
( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'},
56 'IMD segment deals with quoted character at end' );