Koha/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t
Jonathan Druart 2217f98b7c Bug 12827: NewOrder should not return basketno
Since the basketno parameter is needed to insert an order, it is useless
to return it.

This patch changes the prototype for the C4::Acquisition::NewOrder
subroutine. The return value is now a scalar containing the ordernumber
created.

Test plan:
Verify there is no regression on an acquisition workflow:
1/ Create an order with several items
2/ Modify the order
3/ Receive some items
4/ Cancel the receipt
4/ Receive some items
5/ Receive all remaining items
6/ Cancel the receipt

Signed-off-by: Zeno Tajoli <z.tajoli@cineca.it>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-09-17 21:22:26 -03:00

81 lines
1.8 KiB
Perl

#!/usr/bin/perl
use Modern::Perl;
use Test::More;
use C4::Acquisition;
use C4::Biblio;
use C4::Bookseller;
use C4::Budgets;
use MARC::Record;
#Start transaction
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $booksellerid = C4::Bookseller::AddBookseller(
{
name => "my vendor",
address1 => "bookseller's address",
phone => "0123456",
active => 1
}
);
my $basketno = C4::Acquisition::NewBasket(
$booksellerid
);
my $budgetid = C4::Budgets::AddBudget(
{
budget_code => "budget_code_test_getordersbybib",
budget_name => "budget_name_test_getordersbybib",
}
);
my $budget = C4::Budgets::GetBudget( $budgetid );
my ($ordernumber1, $ordernumber2, $ordernumber3);
my ($biblionumber1, $biblioitemnumber1) = AddBiblio(MARC::Record->new, '');
my ($biblionumber2, $biblioitemnumber2) = AddBiblio(MARC::Record->new, '');
$ordernumber1 = C4::Acquisition::NewOrder(
{
basketno => $basketno,
quantity => 24,
biblionumber => $biblionumber1,
budget_id => $budget->{budget_id},
}
);
$ordernumber2 = C4::Acquisition::NewOrder(
{
basketno => $basketno,
quantity => 42,
biblionumber => $biblionumber2,
budget_id => $budget->{budget_id},
}
);
$ordernumber3 = C4::Acquisition::NewOrder(
{
basketno => $basketno,
quantity => 4,
biblionumber => $biblionumber2,
budget_id => $budget->{budget_id},
}
);
my @orders = GetOrdersByBiblionumber();
is(scalar(@orders), 0, 'GetOrdersByBiblionumber : no argument, return undef');
@orders = GetOrdersByBiblionumber( $biblionumber1 );
is(scalar(@orders), 1, '1 order on biblionumber 1');
@orders = GetOrdersByBiblionumber( $biblionumber2 );
is(scalar(@orders), 2, '2 orders on biblionumber 2');
#End transaction
$dbh->rollback;
done_testing;