Bug 10275: UT: OrderFromSubscription.t needs to create its own data
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 17 May 2013 13:27:45 +0000 (15:27 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 16 Jul 2013 14:20:37 +0000 (14:20 +0000)
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 <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes tests.
Assumes Dateformat is set to US dates as in the sample data.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/db_dependent/Acquisition/OrderFromSubscription.t

index 91936a8..aa9a4a3 100644 (file)
@@ -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);
+};