Bug 18083: Simplify the condition - if there are more than 1 library
[koha.git] / t / Ediorder.t
blob5332f0c5ae4d43fca55eaaea9f87e23d0fa7c8fc
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
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
15 my $processed_text =
16 Koha::Edifact::Order::encode_text(q{string containing ?,',:,+});
18 cmp_ok(
19 $processed_text, 'eq',
20 q{string containing ??,?',?:,?+},
21 'Outgoing text correctly quoted'
24 # extend above test to test chunking in imd_segment
26 my $code = '010';
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 );
42 cmp_ok(
43 $segs[0],
44 'eq',
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' );