Bugzilla – Attachment 128419 Details for
Bug 29670
Restore functionality broken by bug 27708 for AcqCreateItem set to "placing an order"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29670: Unit tests
Bug-29670-Unit-tests.patch (text/plain), 7.48 KB, created by
Katrin Fischer
on 2021-12-12 14:43:33 UTC
(
hide
)
Description:
Bug 29670: Unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2021-12-12 14:43:33 UTC
Size:
7.48 KB
patch
obsolete
>From 330e5cc184f232f7cd1b94787d3157d9c1cf3732 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 9 Dec 2021 16:04:55 +0000 >Subject: [PATCH] Bug 29670: Unit tests > >This patch adds unit tests for Koha::Edifact::Order->order_line. We now >check that the message segments are created as expected for both the >'ordering' and not 'ordering' case for acquisitions item creation time. > >Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Koha/Edifact/Order.t | 121 +++++++++++++++++++++++++++++++++--- > 1 file changed, 112 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Koha/Edifact/Order.t b/t/db_dependent/Koha/Edifact/Order.t >index 667e079638..32cf3a2363 100755 >--- a/t/db_dependent/Koha/Edifact/Order.t >+++ b/t/db_dependent/Koha/Edifact/Order.t >@@ -32,18 +32,55 @@ 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 => 2; >+ plan tests => 24; > > $schema->storage->txn_begin; > > my $biblio = $builder->build_sample_biblio(); >+ my $biblioitem = $biblio->biblioitem; >+ $biblioitem->update({ isbn => '979-8572072303' }); >+ my $biblioitem_itype = $biblioitem->itemtype; >+ >+ my $item1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ location => 'PROCESSING', >+ itemcallnumber => '000.101' >+ } >+ ); >+ my $item1_homebranch = $item1->homebranch; >+ my $item1_itype = $item1->effective_itemtype; >+ my $item2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ location => 'PROCESSING', >+ itemcallnumber => '000.102' >+ } >+ ); >+ my $item2_homebranch = $item2->homebranch; >+ my $item2_itype = $item2->effective_itemtype; >+ > my $ean = $builder->build( { source => 'EdifactEan' } ); >- my $order = $builder->build_object( >+ my $dbic_ean = $schema->resultset('EdifactEan')->find($ean->{ee_id}); >+ my $order = $builder->build_object( > { > class => 'Koha::Acquisition::Orders', >- value => { biblionumber => $biblio->biblionumber } >+ value => { >+ biblionumber => $biblio->biblionumber, >+ quantity => 2, >+ line_item_id => 'EDILINEID1', >+ order_vendornote => 'A not so pretty note', >+ listprice => '1.50' >+ } > } > ); >+ my $ordernumber = $order->ordernumber; >+ my $supplier_qualifier = $order->suppliers_reference_qualifier; >+ my $supplier_ordernumber = $order->suppliers_reference_number; >+ my $budgetcode = $order->fund->budget_code; >+ my $deliveryplace = $order->basket->deliveryplace; >+ $order->add_item($item1->itemnumber); >+ $order->add_item($item2->itemnumber); > > my $vendor = $builder->build( > { >@@ -53,6 +90,7 @@ subtest 'order_line() tests' => sub { > } > } > ); >+ my $dbic_vendor = $schema->resultset('VendorEdiAccount')->find($vendor->{id}); > > my @orders = $schema->resultset('Aqorder') > ->search( { basketno => $order->basket->basketno } )->all; >@@ -60,20 +98,85 @@ subtest 'order_line() tests' => sub { > my $edi_order = Koha::Edifact::Order->new( > { > orderlines => \@orders, >- vendor => $vendor, >- ean => $ean >+ vendor => $dbic_vendor, >+ ean => $dbic_ean > } > ); > >- $order->basket->create_items('ordering')->store; >+ # FIXME: Add test for an order where the attached biblio has been deleted. > >+ $order->basket->create_items('ordering')->store; > is( $edi_order->order_line( 1, $orders[0] ), >- undef, 'Orderline message formed with with "ordering"' ); >+ undef, 'order_line run for message formed with effective_create_items = "ordering"' ); >+ >+ my $segs = $edi_order->{segs}; >+ is( $segs->[0], 'LIN+1++EDILINEID1:EN\'', 'LIN segment added containing order->line_item_id' ); >+ is( $segs->[1], 'PIA+5+8572072303:IB\'', 'PIA segment added with example biblioitem->isbn13' ); >+ is( $segs->[2], 'IMD+L+009+:::Some boring author\'', 'IMD segment added containing demo data author' ); >+ is( $segs->[3], 'IMD+L+050+:::Some boring read\'', 'IMD segment added containing demo data title' ); >+ is( $segs->[4], 'QTY+21:2\'', 'QTY segement added containing the number of items expected' ); >+ is( >+ $segs->[5], >+ 'GIR+001' >+ . "+$budgetcode:LFN" >+ . "+$item1_homebranch:LLO" >+ . "+$item1_itype:LST" >+ . "+PROCESSING:LSQ" >+ . "+000.101:LSM" >+ . "'", >+ 'GIR segment added for first item and contains item record data' >+ ); >+ is( >+ $segs->[6], >+ 'GIR+002' >+ . "+$budgetcode:LFN" >+ . "+$item2_homebranch:LLO" >+ . "+$item2_itype:LST" >+ . "+PROCESSING:LSQ" >+ . "+000.102:LSM" >+ . "'", >+ 'GIR segment added for second item and contains item record data' >+ ); >+ is( $segs->[7], 'FTX+LIN+++A not so pretty note\'', 'FTX segment added containing data from vendor_note' ); >+ is( $segs->[8], 'PRI+AAE:1.50:CA\'', 'PRI segment added containing data orderline listprice' ); >+ 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' ); > >- $order->basket->create_items('receiving')->store; >+ # Reset segments for effective_create_items = 'receiving' >+ $edi_order->{segs} = []; > >+ $order->basket->create_items('receiving')->store; > is( $edi_order->order_line( 1, $orders[0] ), >- undef, 'Orderline message formed with "receiving"' ); >+ undef, 'order_line run for message formed with effective_create_items = "receiving"' ); >+ >+ $segs = $edi_order->{segs}; >+ is( $segs->[0], 'LIN+1++EDILINEID1:EN\'', 'LIN segment added containing order->line_item_id' ); >+ is( $segs->[1], 'PIA+5+8572072303:IB\'', 'PIA segment added with example biblioitem->isbn13' ); >+ is( $segs->[2], 'IMD+L+009+:::Some boring author\'', 'IMD segment added containing demo data author' ); >+ is( $segs->[3], 'IMD+L+050+:::Some boring read\'', 'IMD segment added containing demo data title' ); >+ is( $segs->[4], 'QTY+21:2\'', 'QTY segement added containing the number of items expected' ); >+ is( >+ $segs->[5], >+ 'GIR+001' >+ . "+$budgetcode:LFN" >+ . "+$deliveryplace:LLO" >+ . "+$biblioitem_itype:LST" >+ . "'", >+ 'GIR segment added for first item and contains biblioitem data' >+ ); >+ is( >+ $segs->[6], >+ 'GIR+002' >+ . "+$budgetcode:LFN" >+ . "+$deliveryplace:LLO" >+ . "+$biblioitem_itype:LST" >+ . "'", >+ 'GIR segment added for second item and contains biblioitem data' >+ ); >+ is( $segs->[7], 'FTX+LIN+++A not so pretty note\'', 'FTX segment added containing data from vendor_note' ); >+ is( $segs->[8], 'PRI+AAE:1.50:CA\'', 'PRI segment added containing data orderline listprice' ); >+ 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' ); > > $schema->storage->txn_rollback; > }; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29670
:
128375
|
128379
|
128391
|
128392
|
128393
|
128394
|
128419
|
128420
|
129584
|
129585