@ -23,6 +23,7 @@ use Test::More tests => 3;
use Koha::Edifact::Order ;
use t::lib::Mocks ;
use t::lib::TestBuilder ;
my $ schema = Koha::Database - > new - > schema ;
@ -58,7 +59,7 @@ subtest 'beggining_of_message tests' => sub {
subtest 'order_line() tests' = > sub {
# TODO: Split up order_line() to smaller methods in order
# to allow better testing
plan tests = > 24 ;
plan tests = > 27 ;
$ schema - > storage - > txn_begin ;
@ -71,6 +72,7 @@ subtest 'order_line() tests' => sub {
{
biblionumber = > $ biblio - > biblionumber ,
location = > 'PROCESSING' ,
ccode = > 'COLLECTION' ,
itemcallnumber = > '000.101'
}
) ;
@ -80,6 +82,7 @@ subtest 'order_line() tests' => sub {
{
biblionumber = > $ biblio - > biblionumber ,
location = > 'PROCESSING' ,
ccode = > 'COLLECTION' ,
itemcallnumber = > '000.102'
}
) ;
@ -131,6 +134,9 @@ subtest 'order_line() tests' => sub {
# FIXME: Add test for an order where the attached biblio has been deleted.
# Set EdifactLSQ field to default
t::lib::Mocks:: mock_preference ( 'EdifactLSQ' , 'location' ) ;
$ order - > basket - > create_items ( 'ordering' ) - > store ;
is ( $ edi_order - > order_line ( 1 , $ orders [ 0 ] ) ,
undef , 'order_line run for message formed with effective_create_items = "ordering"' ) ;
@ -204,6 +210,40 @@ subtest 'order_line() tests' => sub {
is ( $ segs - > [ 9 ] , "RFF+LI:$ordernumber'" , 'RFF segment added containing koha orderline id' ) ;
is ( $ segs - > [ 10 ] , "RFF+$supplier_qualifier:$supplier_ordernumber'" , 'RFF segment added containing supplier orderline id' ) ;
# Reset segments for testing EdifactLSQ preference
$ edi_order - > { segs } = [] ;
# Set EdifactLSQ field to ccode
t::lib::Mocks:: mock_preference ( 'EdifactLSQ' , 'ccode' ) ;
$ order - > basket - > create_items ( 'ordering' ) - > store ;
is ( $ edi_order - > order_line ( 1 , $ orders [ 0 ] ) ,
undef , 'order_line run for message formed with EdifactLSQ = "ccode"' ) ;
$ segs = $ edi_order - > { segs } ;
is (
$ segs - > [ 5 ] ,
'GIR+001'
. "+$budgetcode:LFN"
. "+$item1_homebranch:LLO"
. "+$item1_itype:LST"
. "+COLLECTION:LSQ"
. "+000.101:LSM"
. "'" ,
'GIR segment added for first item and contains item ccode data'
) ;
is (
$ segs - > [ 6 ] ,
'GIR+002'
. "+$budgetcode:LFN"
. "+$item2_homebranch:LLO"
. "+$item2_itype:LST"
. "+COLLECTION:LSQ"
. "+000.102:LSM"
. "'" ,
'GIR segment added for second item and contains item ccode data'
) ;
$ schema - > storage - > txn_rollback ;
} ;