Bug 10575 : GetOrdersByBiblionumber.t needs a database transaction
authorKenza Zaki <kenza.zaki@biblibre.com>
Thu, 11 Jul 2013 14:28:11 +0000 (16:28 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 15 Jul 2013 16:20:53 +0000 (16:20 +0000)
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>
t/db_dependent/Acquisition/GetOrdersByBiblionumber.t

index c801dd7..8bd0735 100644 (file)
@@ -9,6 +9,11 @@ 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",
@@ -70,15 +75,7 @@ is(scalar(@orders), 1, '1 order on biblionumber 1');
 @orders = GetOrdersByBiblionumber( $biblionumber2 );
 is(scalar(@orders), 2, '2 orders on biblionumber 2');
 
-END {
-    C4::Acquisition::DelOrder( 1, $ordernumber1 );
-    C4::Acquisition::DelOrder( 2, $ordernumber2 );
-    C4::Acquisition::DelOrder( 3, $ordernumber3 );
-    C4::Budgets::DelBudget( $budgetid );
-    C4::Acquisition::DelBasket( $basketno );
-    C4::Bookseller::DelBookseller( $booksellerid );
-    C4::Biblio::DelBiblio($biblionumber1);
-    C4::Biblio::DelBiblio($biblionumber2);
-};
+#End transaction
+$dbh->rollback;
 
 done_testing;