X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=t%2FEdiorder.t;h=1b89f8a9c5e220cef18384039d34ad18de4a4c50;hb=241c8cc03d02b78de731f5312d53c1641dec0d2a;hp=50926a9127bbf943e3cd06c28c4b75f84970539f;hpb=047c5f0895606104dc5e3db798cd6b7f70a23dba;p=koha-ffzg.git diff --git a/t/Ediorder.t b/t/Ediorder.t index 50926a9127..1b89f8a9c5 100755 --- a/t/Ediorder.t +++ b/t/Ediorder.t @@ -3,13 +3,14 @@ use strict; use warnings; use FindBin qw( $Bin ); -use Test::More tests => 8; +use Test::More tests => 13; +use t::lib::Mocks; BEGIN { use_ok('Koha::Edifact::Order') } - +t::lib::Mocks::mock_preference('EdifactLSQ', 'location'); # The following tests are for internal methods but they could -# error spectacularly so yest +# error spectacularly so best # Check that quoting is done correctly # my $processed_text = @@ -55,6 +56,20 @@ $data_to_encode .= '??'; cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, 'IMD segment deals with quoted character at end' ); +# special case for text ending in apostrophe e.g. nuthin' +$data_to_encode .= q{?'}; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( + $segs[1], 'eq', + q{IMD+L+010+:::CCCCCCCCCC???''}, + 'IMD segment deals with quoted apostrophe at end' +); + +$data_to_encode =~ s/\?'$//; +@segs = Koha::Edifact::Order::imd_segment( $code, $data_to_encode ); +cmp_ok( $segs[1], 'eq', q{IMD+L+010+:::CCCCCCCCCC??'}, + 'IMD segment deals with apostrophe preceded by quoted ? at end' ); + my $isbn = '3540556753'; my $ean = '9783540556756'; @@ -65,3 +80,47 @@ cmp_ok( $seg, 'eq', q{PIA+5+3540556753:IB'}, $seg = Koha::Edifact::Order::additional_product_id($ean); cmp_ok( $seg, 'eq', q{PIA+5+9783540556756:EN'}, 'ean correctly encoded in PIA segment' ); + +my $orderfields = { budget_code => 'BUDGET', }; +my @items = ( + { + itype => 'TYPE', + location => 'LOCATION', + itemcallnumber => 'CALL', + branchcode => 'BRANCH', + }, + { + itype => 'TYPE', + location => 'LOCATION', + itemcallnumber => 'CALL', + branchcode => 'BRANCH', + } +); + +my @gsegs = Koha::Edifact::Order::gir_segments( + { + ol_fields => $orderfields, + items => \@items + } +); +cmp_ok( + $gsegs[0], 'eq', + q{GIR+001+BUDGET:LFN+BRANCH:LLO+TYPE:LST+LOCATION:LSQ+CALL:LSM}, + 'Single Gir field OK' +); + +$orderfields->{servicing_instruction} = 'S_I'; +@gsegs = Koha::Edifact::Order::gir_segments( + { + ol_fields => $orderfields, + items => \@items + } +); +cmp_ok( + $gsegs[2], 'eq', + q{GIR+002+BUDGET:LFN+BRANCH:LLO+TYPE:LST+LOCATION:LSQ+CALL:LSM}, + 'First part of split Gir field OK' +); + +cmp_ok( $gsegs[3], 'eq', q{GIR+002+S_I:LVT}, + 'Second part of split GIR field OK' );