From dae21ecf0f30ce9f87dd7e623abbff98d48756b7 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 Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- 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 0974396dcb..3630a8172d 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 => 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; }; -- 2.20.1