|
Lines 3-15
use strict;
Link Here
|
| 3 |
use warnings; |
3 |
use warnings; |
| 4 |
use FindBin qw( $Bin ); |
4 |
use FindBin qw( $Bin ); |
| 5 |
|
5 |
|
| 6 |
use Test::More tests => 10; |
6 |
use Test::More tests => 13; |
| 7 |
|
7 |
|
| 8 |
BEGIN { use_ok('Koha::Edifact::Order') } |
8 |
BEGIN { use_ok('Koha::Edifact::Order') } |
| 9 |
|
9 |
|
| 10 |
|
|
|
| 11 |
# The following tests are for internal methods but they could |
10 |
# The following tests are for internal methods but they could |
| 12 |
# error spectacularly so yest |
11 |
# error spectacularly so best |
| 13 |
# Check that quoting is done correctly |
12 |
# Check that quoting is done correctly |
| 14 |
# |
13 |
# |
| 15 |
my $processed_text = |
14 |
my $processed_text = |
|
Lines 58-67
cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'},
Link Here
|
| 58 |
# special case for text ending in apostrophe e.g. nuthin' |
57 |
# special case for text ending in apostrophe e.g. nuthin' |
| 59 |
$data_to_encode .= q{?'}; |
58 |
$data_to_encode .= q{?'}; |
| 60 |
@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); |
59 |
@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); |
| 61 |
cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC???''}, |
60 |
cmp_ok( |
| 62 |
'IMD segment deals with quoted apostrophe at end' ); |
61 |
$segs[1], 'eq', |
|
|
62 |
q{IMD+L+010+:::CCCCCCCCCC???''}, |
| 63 |
'IMD segment deals with quoted apostrophe at end' |
| 64 |
); |
| 63 |
|
65 |
|
| 64 |
$data_to_encode =~s/\?'$//; |
66 |
$data_to_encode =~ s/\?'$//; |
| 65 |
@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); |
67 |
@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); |
| 66 |
cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, |
68 |
cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, |
| 67 |
'IMD segment deals with apostrophe preceded by quoted ? at end' ); |
69 |
'IMD segment deals with apostrophe preceded by quoted ? at end' ); |
|
Lines 76-78
cmp_ok( $seg, 'eq', q{PIA+5+3540556753:IB'},
Link Here
|
| 76 |
$seg = Koha::Edifact::Order::additional_product_id($ean); |
78 |
$seg = Koha::Edifact::Order::additional_product_id($ean); |
| 77 |
cmp_ok( $seg, 'eq', q{PIA+5+9783540556756:EN'}, |
79 |
cmp_ok( $seg, 'eq', q{PIA+5+9783540556756:EN'}, |
| 78 |
'ean correctly encoded in PIA segment' ); |
80 |
'ean correctly encoded in PIA segment' ); |
| 79 |
- |
81 |
|
|
|
82 |
my $orderfields = { budget_code => 'BUDGET', }; |
| 83 |
my @items = ( |
| 84 |
{ |
| 85 |
itype => 'TYPE', |
| 86 |
location => 'LOCATION', |
| 87 |
itemcallnumber => 'CALL', |
| 88 |
branchcode => 'BRANCH', |
| 89 |
}, |
| 90 |
{ |
| 91 |
itype => 'TYPE', |
| 92 |
location => 'LOCATION', |
| 93 |
itemcallnumber => 'CALL', |
| 94 |
branchcode => 'BRANCH', |
| 95 |
} |
| 96 |
); |
| 97 |
|
| 98 |
my @gsegs = Koha::Edifact::Order::gir_segments( |
| 99 |
{ |
| 100 |
ol_fields => $orderfields, |
| 101 |
items => \@items |
| 102 |
} |
| 103 |
); |
| 104 |
cmp_ok( |
| 105 |
$gsegs[0], 'eq', |
| 106 |
q{GIR+001+BUDGET:LFN+BRANCH:LLO+TYPE:LST+LOCATION:LSQ+CALL:LSM}, |
| 107 |
'Single Gir field OK' |
| 108 |
); |
| 109 |
|
| 110 |
$orderfields->{servicing_instruction} = 'S_I'; |
| 111 |
@gsegs = Koha::Edifact::Order::gir_segments( |
| 112 |
{ |
| 113 |
ol_fields => $orderfields, |
| 114 |
items => \@items |
| 115 |
} |
| 116 |
); |
| 117 |
cmp_ok( |
| 118 |
$gsegs[2], 'eq', |
| 119 |
q{GIR+002+BUDGET:LFN+BRANCH:LLO+TYPE:LST+LOCATION:LSQ+CALL:LSM}, |
| 120 |
'First part of split Gir field OK' |
| 121 |
); |
| 122 |
|
| 123 |
cmp_ok( $gsegs[3], 'eq', q{GIR+002+S_I:LVT}, |
| 124 |
'Second part of split GIR field OK' ); |