@@ -, +, @@ prove t/db_dependent/Acquisition.t --- t/db_dependent/Acquisition.t | 449 +------------------------------------------ 1 file changed, 1 insertion(+), 448 deletions(-) --- a/t/db_dependent/Acquisition.t +++ a/t/db_dependent/Acquisition.t @@ -19,7 +19,7 @@ use Modern::Perl; use POSIX qw(strftime); -use Test::More tests => 92; +use Test::More tests => 65; use Koha::Database; BEGIN { @@ -273,393 +273,7 @@ for ( 0 .. 4 ) { $order_content[$_]->{str}->{ordernumber} = $ordernumbers[$_]; } -# Test UT sub _check_fields_of_order - -my ( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_order( - [qw /a b c d e/], - { str => { a => "bla", b => "105" }, num => { c => 15.12 } }, - { a => "blabla", f => "f", b => "105", c => 15.1200, g => '' } - ); -ok( - ( - ( $test_nbr_fields == 5 ) - and ( join( " ", sort @$test_missing_fields ) eq 'd e' ) - and ( join( " ", sort @$test_extra_fields ) eq 'f g' ) - and ( join( " ", @$test_different_fields ) eq 'a' ) - ), - "_check_fields_of_order can check an order (test 1)" -); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_order( - [qw /a b c /], - { str => { a => "bla", b => "105" }, num => { c => 15.00 } }, - { a => "bla", b => "105", c => 15 } - ); -ok( - ( - ( $test_nbr_fields == 3 ) - and ( scalar @$test_missing_fields == 0 ) - and ( scalar @$test_extra_fields == 0 ) - and ( scalar @$test_different_fields == 0 ) - ), - "_check_fields_of_order can check an order (test 2)" -); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_order( - [qw /a b c d e/], - { str => { a => "bla", b => "105" }, num => { c => 15.12 } }, - { a => "blabla", b => "105", c => 15, d => "error" } - ); -ok( - ( - ( $test_nbr_fields == 4 ) - and ( join( " ", sort @$test_missing_fields ) eq 'e' ) - and ( scalar @$test_extra_fields == 0 ) - and ( join( " ", @$test_different_fields ) eq 'a c' ) - ), - "_check_fields_of_order can check an order (test 3)" -); - -# -# test GetOrder -# - -my @expectedfields = qw( - order_internalnote - order_vendornote - ordernumber - biblionumber - entrydate - quantity - currency - listprice - datereceived - invoiceid - freight - unitprice - unitprice_tax_included - unitprice_tax_excluded - quantityreceived - datecancellationprinted - purchaseordernumber - basketno - timestamp - rrp - rrp_tax_included - rrp_tax_excluded - ecost - ecost_tax_included - ecost_tax_excluded - unitpricesupplier - unitpricelib - tax_rate - tax_value - discount - budget_id - budgetdate - sort1 - sort2 - sort1_authcat - sort2_authcat - uncertainprice - claims_count - claimed_date - subscriptionid - parent_ordernumber - orderstatus - line_item_id - suppliers_reference_number - suppliers_reference_qualifier - suppliers_report - title - author - basketname - branchcode - publicationyear - copyrightdate - editionstatement - isbn - ean - seriestitle - publishercode - publisher - budget - supplier - supplierid - estimateddeliverydate - orderdate - quantity_to_receive - subtotal - latesince - cancellationreason -); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_order( \@expectedfields, $order_content[0], - GetOrder( $ordernumbers[0] ) ); -is( - $test_nbr_fields, - scalar @expectedfields, - "GetOrder gets an order with the right number of fields" -); -is( join( " ", @$test_missing_fields ), - '', "GetOrder gets an order with no missing fields" ); -is( join( " ", @$test_extra_fields ), - '', "GetOrder gets an order with no unexpected fields" ); -is( join( " ", @$test_different_fields ), - '', "GetOrder gets an order with the right content in every fields" ); - -# -# Test GetOrders -# - -my @base_expectedfields = qw( - order_internalnote - order_vendornote - notes - ordernumber - ecost - ecost_tax_included - ecost_tax_excluded - uncertainprice - url - isbn - copyrightdate - serial - cn_suffix - cn_item - marcxml - freight - cn_class - title - pages - budget_encumb - budget_name - number - itemtype - totalissues - author - budget_permission - parent_ordernumber - size - claims_count - currency - seriestitle - timestamp - editionstatement - budget_parent_id - publishercode - unitprice - unitprice_tax_included - unitprice_tax_excluded - collectionvolume - budget_amount - budget_owner_id - datecreated - claimed_date - subscriptionid - editionresponsibility - sort2 - volumedate - budget_id - illus - ean - biblioitemnumber - datereceived - orderstatus - line_item_id - suppliers_reference_number - suppliers_reference_qualifier - suppliers_report - agerestriction - budget_branchcode - tax_rate - tax_value - listprice - budget_code - budgetdate - basketno - discount - abstract - collectionissn - publicationyear - collectiontitle - invoiceid - place - issn - quantityreceived - entrydate - cn_source - sort1_authcat - budget_notes - biblionumber - unititle - sort2_authcat - budget_expend - rrp - rrp_tax_included - rrp_tax_excluded - cn_sort - lccn - sort1 - volume - purchaseordernumber - quantity - budget_period_id - frameworkcode - volumedesc - datecancellationprinted - cancellationreason -); -@expectedfields = - ( @base_expectedfields, - ( 'transferred_from_timestamp', 'transferred_from' ) ); -is( GetOrders(), undef, "GetOrders with no params returns undef" ); DelOrder( $order_content[3]->{str}->{biblionumber}, $ordernumbers[3] ); -my @get_orders = GetOrders($basketno); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_orders( \@expectedfields, \@order_content, \@get_orders ); -is( - $$test_nbr_fields[0], - scalar @expectedfields, - "GetOrders gets orders with the right number of fields" -); -is( join( " ", @$test_missing_fields ), - '', "GetOrders gets orders with no missing fields" ); -is( join( " ", @$test_extra_fields ), - '', "GetOrders gets orders with no unexpected fields" ); -is( join( " ", @$test_different_fields ), - '', "GetOrders gets orders with the right content in every fields" ); -ok( - ( - ( scalar @get_orders == 4 ) - and !grep ( $_->{ordernumber} eq $ordernumbers[3], @get_orders ) - ), - "GetOrders only gets non-cancelled orders" -); - -# -# Test GetOrders { cancelled => 1 } -# - -@expectedfields = - ( @base_expectedfields, ( 'transferred_to_timestamp', 'transferred_to' ) ); -@get_orders = GetOrders($basketno, { cancelled => 1 }); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_orders( \@expectedfields, \@order_content, \@get_orders ); -is( - $$test_nbr_fields[0], - scalar @expectedfields, - "GetOrders { cancelled => 1 } gets orders with the right number of fields" -); -is( join( " ", @$test_missing_fields ), - '', "GetOrders { cancelled => 1 } gets orders with no missing fields" ); -is( join( " ", @$test_extra_fields ), - '', "GetOrders { cancelled => 1 } gets orders with no unexpected fields" ); -is( join( " ", @$test_different_fields ), - '', - "GetOrders { cancelled => 1 } gets orders with the right content in every fields" ); -ok( - ( - ( scalar @get_orders == 1 ) - and grep ( $_->{ordernumber} eq $ordernumbers[3], @get_orders ) - ), - "GetOrders { cancelled => 1 } only gets cancelled orders" -); - -# -# Test SearchOrders -# - -@expectedfields = qw ( - order_internalnote - order_vendornote - notes - basketgroupid - basketgroupname - firstname - biblioitemnumber - ecost - ecost_tax_included - ecost_tax_excluded - uncertainprice - creationdate - datereceived - orderstatus - line_item_id - suppliers_reference_number - suppliers_reference_qualifier - suppliers_report - isbn - copyrightdate - tax_rate - tax_value - serial - listprice - budgetdate - basketno - discount - surname - freight - abstract - title - closedate - basketname - invoiceid - author - parent_ordernumber - claims_count - entrydate - currency - quantityreceived - seriestitle - sort1_authcat - timestamp - biblionumber - unititle - sort2_authcat - rrp - rrp_tax_included - rrp_tax_excluded - unitprice - unitprice_tax_included - unitprice_tax_excluded - sort1 - ordernumber - datecreated - purchaseordernumber - quantity - claimed_date - subscriptionid - frameworkcode - sort2 - datecancellationprinted - budget_id - authorisedby - booksellerid - cancellationreason -); - -# note that authorisedby was added to the return of SearchOrder by the -# patch for bug 11777 my $invoiceid = AddInvoice( invoicenumber => 'invoice', @@ -684,23 +298,6 @@ my $search_orders = SearchOrders({ basketno => $basketno }); isa_ok( $search_orders, 'ARRAY' ); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_orders( \@expectedfields, \@order_content, - $search_orders ); -is( - $$test_nbr_fields[0], - scalar @expectedfields, - "SearchOrders gets orders with the right number of fields" -); -is( join( " ", @$test_missing_fields ), - '', "SearchOrders gets orders with no missing fields" ); -is( join( " ", @$test_extra_fields ), - '', "SearchOrders gets orders with no unexpected fields" ); -is( join( " ", @$test_different_fields ), - '', "SearchOrders gets orders with the right content in every fields" ); ok( ( ( scalar @$search_orders == 4 ) @@ -755,34 +352,6 @@ is( scalar (@$search_orders), 0, "SearchOrders takes into account the biblionumb ok( GetBudgetByOrderNumber( $ordernumbers[0] )->{'budget_id'} eq $budgetid, "GetBudgetByOrderNumber returns expected budget" ); -# -# Test GetLateOrders -# - -@expectedfields = qw ( - orderdate - author - budget - supplierid - claims_count - supplier - publisher - ordernumber - quantity - basketno - claimed_date - branch - estimateddeliverydate - title - publicationyear - unitpricelib - unitpricesupplier - subtotal - latesince - basketname - basketgroupid - basketgroupname -); my @lateorders = GetLateOrders(0); is( scalar grep ( $_->{basketno} eq $basketno, @lateorders ), 0, "GetLateOrders does not get orders from opened baskets" ); @@ -794,22 +363,6 @@ ok( !grep ( $_->{ordernumber} eq $ordernumbers[3], @lateorders ), "GetLateOrders does not gets cancelled orders" ); ok( !grep ( $_->{ordernumber} eq $ordernumbers[4], @lateorders ), "GetLateOrders does not gets reveived orders" ); -( - $test_missing_fields, $test_extra_fields, - $test_different_fields, $test_nbr_fields - ) - = _check_fields_of_orders( \@expectedfields, \@order_content, \@lateorders ); -is( - $$test_nbr_fields[0], - scalar @expectedfields, - "GetLateOrders gets orders with the right number of fields" -); -is( join( " ", @$test_missing_fields ), - '', "GetLateOrders gets orders with no missing fields" ); -is( join( " ", @$test_extra_fields ), - '', "GetLateOrders gets orders with no unexpected fields" ); -is( join( " ", @$test_different_fields ), - '', "GetLateOrders gets orders with the right content in every fields" ); $search_orders = SearchOrders({ booksellerid => $booksellerid, --