From 5b1fda0cf3bb86c04db73d4992a09ceca2f6c9d9 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 Signed-off-by: Katrin Fischer Passes tests. Assumes Dateformat is set to US dates as in the sample data. Signed-off-by: Galen Charlton (cherry picked from commit 8e442955247e925dacf303455f40522a89a349b2) Signed-off-by: Tomas Cohen Arazi --- .../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 91936a8fb0..aa9a4a34f1 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); +}; -- 2.39.5