From 1df979f48f4a62a825badb56a2ecb28568806b95 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 17 May 2013 15:27:45 +0200 Subject: [PATCH] Bug 10275: UT: OrderFromSubscription.t needs to create its own data Try before the patch: prove t/db_dependent/Acquisition/OrderFromSubscription.t And after, it should produce: t/db_dependent/Acquisition/OrderFromSubscription.t .. ok All tests successful. Files=1, Tests=12, 2 wallclock secs ( 0.02 usr 0.00 sys + 0.46 cusr 0.02 csys = 0.50 CPU) Result: PASS And some warnings... Signed-off-by: Chris Cormack --- t/db_dependent/Acquisition/OrderFromSubscription.t | 41 ++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/t/db_dependent/Acquisition/OrderFromSubscription.t b/t/db_dependent/Acquisition/OrderFromSubscription.t index 91936a8..aa9a4a3 100644 --- a/t/db_dependent/Acquisition/OrderFromSubscription.t +++ b/t/db_dependent/Acquisition/OrderFromSubscription.t @@ -1,19 +1,29 @@ use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 12; use Data::Dumper; -use_ok('C4::Serials'); -use_ok('C4::Budgets'); use_ok('C4::Acquisition'); +use_ok('C4::Biblio'); +use_ok('C4::Budgets'); +use_ok('C4::Serials'); my $supplierlist=eval{GetSuppliersWithLateIssues()}; ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues"); -my $biblionumber = 1; +my $booksellerid = C4::Bookseller::AddBookseller( + { + name => "my vendor", + address1 => "bookseller's address", + phone => "0123456", + active => 1 + } +); + +my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); my $budgetid; my $bpid = AddBudgetPeriod({ budget_period_startdate => '01-01-2015', - budget_period_enddate => '31-12-2015', + budget_period_enddate => '12-31-2015', budget_description => "budget desc" }); @@ -36,16 +46,21 @@ my $subscriptionid = NewSubscription( "intnotes", 0, undef, undef, 0, undef, '31-12-2013', ); die unless $subscriptionid; + +my ($basket, $basketno); +ok($basketno = NewBasket($booksellerid, 1), "NewBasket( $booksellerid , 1 ) returns $basketno"); + my $cost = 42.00; my $subscription = GetSubscription( $subscriptionid ); -my ( $basketno, $ordernumber ) = NewOrder({ +my $ordernumber; +( $basketno, $ordernumber ) = NewOrder({ biblionumber => $subscription->{biblionumber}, entrydate => '01-01-2013', quantity => 1, currency => 'USD', listprice => $cost, notes => "This is a note", - basketno => 1, + basketno => $basketno, rrp => $cost, ecost => $cost, gstrate => 0.0500, @@ -73,7 +88,11 @@ $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscription is ( $order, undef, "test no not received order for a received order"); # cleaning -DelSubscription( $subscription->{subscriptionid} ); -DelOrder( $subscription->{biblionumber}, $ordernumber ); -DelBudgetPeriod($bpid); -DelBudget($budget_id); +END { + DelSubscription( $subscription->{subscriptionid} ); + DelOrder( $subscription->{biblionumber}, $ordernumber ); + DelBudgetPeriod($bpid); + DelBudget($budget_id); + DelBasket( $basketno ); + DelBiblio($biblionumber); +}; -- 1.7.10.4