From 130768ea852afd4e07a44221bd89869b0565ec71 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 21 Feb 2022 17:02:42 +0000 Subject: [PATCH] Bug 30135: Unit tests Add a unit test for EdifactLSQ preference. Signed-off-by: Katrin Fischer --- t/db_dependent/Koha/Edifact/Order.t | 42 ++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Edifact/Order.t b/t/db_dependent/Koha/Edifact/Order.t index 32a07db8ba..895069d59b 100755 --- a/t/db_dependent/Koha/Edifact/Order.t +++ b/t/db_dependent/Koha/Edifact/Order.t @@ -23,6 +23,7 @@ use Test::More tests => 2; use Koha::Edifact::Order; +use t::lib::Mocks; use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; @@ -32,7 +33,7 @@ my $builder = t::lib::TestBuilder->new; 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; @@ -45,6 +46,7 @@ subtest 'order_line() tests' => sub { { biblionumber => $biblio->biblionumber, location => 'PROCESSING', + ccode => 'COLLECTION', itemcallnumber => '000.101' } ); @@ -54,6 +56,7 @@ subtest 'order_line() tests' => sub { { biblionumber => $biblio->biblionumber, location => 'PROCESSING', + ccode => 'COLLECTION', itemcallnumber => '000.102' } ); @@ -105,6 +108,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"' ); @@ -178,6 +184,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; }; -- 2.30.2