45fafb31ce
Before this patch, the queries in GetOrdersByBiblionumber.t were commited in the database and have to be removed at the end. This patch wraps tests in a database transaction. Test Plan : prove t/db_dependent/Acquisition/GetOrdersByBiblionumber.t t/db_dependent/Acquisition/GetOrdersByBiblionumber.t .. ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.37 cusr 0.05 csys = 0.45 CPU) Result: PASS Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Tests pass. Signed-off-by: Galen Charlton <gmc@esilibrary.com>
81 lines
1.9 KiB
Perl
81 lines
1.9 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, '');
|
|
( undef, $ordernumber1 ) = C4::Acquisition::NewOrder(
|
|
{
|
|
basketno => $basketno,
|
|
quantity => 24,
|
|
biblionumber => $biblionumber1,
|
|
budget_id => $budget->{budget_id},
|
|
}
|
|
);
|
|
|
|
( undef, $ordernumber2 ) = C4::Acquisition::NewOrder(
|
|
{
|
|
basketno => $basketno,
|
|
quantity => 42,
|
|
biblionumber => $biblionumber2,
|
|
budget_id => $budget->{budget_id},
|
|
}
|
|
);
|
|
|
|
( undef, $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;
|