Browse Source

Bug 13967: (QA followup) Make DBIx control transactions on tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
3.22.x
Tomás Cohen Arazi 9 years ago
parent
commit
2e11350fe3
  1. 8
      t/db_dependent/Acquisition.t
  2. 6
      t/db_dependent/Acquisition/CancelReceipt.t
  3. 8
      t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t
  4. 7
      t/db_dependent/Acquisition/GetOrdersByBiblionumber.t
  5. 6
      t/db_dependent/Acquisition/Invoices.t
  6. 6
      t/db_dependent/Acquisition/NewOrder.t
  7. 6
      t/db_dependent/Acquisition/OrderFromSubscription.t
  8. 7
      t/db_dependent/Acquisition/OrderUsers.t
  9. 7
      t/db_dependent/Acquisition/TransferOrder.t
  10. 8
      t/db_dependent/Acquisition/close_reopen_basket.t

8
t/db_dependent/Acquisition.t

@ -20,6 +20,7 @@ use Modern::Perl;
use POSIX qw(strftime);
use Test::More tests => 87;
use Koha::Database;
BEGIN {
use_ok('C4::Acquisition');
@ -116,8 +117,11 @@ sub _check_fields_of_orders {
);
}
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
# Creating some orders
@ -917,4 +921,4 @@ ok(($order4->{cancellationreason} eq "foobar"), "order has cancellation reason \
ok((not defined GetBiblio($order4->{biblionumber})), "biblio does not exist anymore");
# End of tests for DelOrder
$dbh->rollback;
$schema->storage->txn_rollback();

6
t/db_dependent/Acquisition/CancelReceipt.t

@ -11,13 +11,15 @@ use C4::Bookseller;
use C4::Budgets;
use t::lib::Mocks;
use Koha::Database;
use Koha::DateUtils;
use Koha::Acquisition::Order;
use MARC::Record;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
my $booksellerid1 = C4::Bookseller::AddBookseller(
{
@ -148,4 +150,4 @@ is( $item1->{notforloan}, 9, "The notforloan value has been updated with '9'" );
my $item2 = C4::Items::GetItem( $itemnumber2 );
is( $item2->{notforloan}, 0, "The notforloan value has been updated with '9'" );
$dbh->rollback;
$schema->storage->txn_rollback();

8
t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t

@ -9,11 +9,13 @@ use C4::Biblio qw( AddBiblio );
use C4::Bookseller qw( AddBookseller );
use C4::Budgets qw( AddBudget );
use C4::Context;
use Koha::Database;
use Koha::Acquisition::Order;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $supplierid = C4::Bookseller::AddBookseller(
@ -94,4 +96,4 @@ $baskets = C4::Acquisition::GetBasketsInfosByBookseller( $supplierid, 1 );
is( scalar(@$baskets), 1, 'Basket is closed, test allbasket parameter');
$dbh->rollback
$schema->storage->txn_rollback();

7
t/db_dependent/Acquisition/GetOrdersByBiblionumber.t

@ -7,14 +7,15 @@ use C4::Acquisition;
use C4::Biblio;
use C4::Bookseller;
use C4::Budgets;
use Koha::Database;
use Koha::Acquisition::Order;
use MARC::Record;
#Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $booksellerid = C4::Bookseller::AddBookseller(
@ -81,6 +82,6 @@ is(scalar(@orders), 1, '1 order on biblionumber 1');
is(scalar(@orders), 2, '2 orders on biblionumber 2');
#End transaction
$dbh->rollback;
$schema->storage->txn_rollback();
done_testing;

6
t/db_dependent/Acquisition/Invoices.t

@ -7,6 +7,7 @@ use C4::Bookseller qw( AddBookseller );
use Koha::Acquisition::Order;
use Koha::Acquisition::Bookseller;
use Koha::Database;
use Test::More tests => 24;
@ -14,8 +15,9 @@ BEGIN {
use_ok('C4::Acquisition');
}
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->do(q{DELETE FROM aqinvoices});
@ -193,5 +195,5 @@ my @invoices_linked_to_subscriptions = map{
is_deeply( \@invoices_linked_to_subscriptions, [], "GetInvoices return linked_to_subscriptions: there is no invoices linked to subscriptions yet" );
END {
$dbh and $dbh->rollback;
$dbh and $schema->storage->txn_rollback();
}

6
t/db_dependent/Acquisition/NewOrder.t

@ -8,11 +8,13 @@ use C4::Biblio;
use C4::Bookseller;
use C4::Budgets;
use MARC::Record;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Acquisition::Order;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $booksellerid = C4::Bookseller::AddBookseller(
@ -84,3 +86,5 @@ my $ordernumber = $order->{ordernumber};
$order = Koha::Acquisition::Order->fetch({ ordernumber => $ordernumber });
is( $order->{quantityreceived}, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
is( $order->{entrydate}, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->insert set entrydate to today' );
$schema->storage->txn_rollback();

6
t/db_dependent/Acquisition/OrderFromSubscription.t

@ -9,10 +9,12 @@ use_ok('C4::Budgets');
use_ok('C4::Serials');
use Koha::Acquisition::Order;
use Koha::Database;
# Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $booksellerid = C4::Bookseller::AddBookseller(
@ -109,4 +111,4 @@ my @invoices_linked_to_subscriptions = grep { $_->{is_linked_to_subscriptions} }
is(scalar(@invoices_linked_to_subscriptions), 1, 'GetInvoices() can identify invoices that are linked to a subscription');
# Cleanup
$dbh->rollback;
$schema->storage->txn_rollback();

7
t/db_dependent/Acquisition/OrderUsers.t

@ -5,12 +5,13 @@ use C4::Acquisition;
use C4::Biblio;
use C4::Bookseller;
use C4::Letters;
use Koha::Database;
use Koha::Acquisition::Order;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
# Creating some orders
my $booksellerid = C4::Bookseller::AddBookseller(
@ -108,3 +109,5 @@ ModReceiveOrder(
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
is( scalar( @$messages ), 1, 'The letter has been sent to message queue on receiving the order');
$schema->storage->txn_rollback();

7
t/db_dependent/Acquisition/TransferOrder.t

@ -9,13 +9,16 @@ use C4::Biblio;
use C4::Items;
use C4::Bookseller;
use C4::Budgets;
use Koha::Database;
use Koha::DateUtils;
use Koha::Acquisition::Order;
use MARC::Record;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
my $booksellerid1 = C4::Bookseller::AddBookseller(
{
@ -97,4 +100,4 @@ $order = GetOrder( $newordernumber );
is ( $order->{ordernumber}, $newordernumber, 'Regression test Bug 11549: After a transfer, receive and cancel the receive should be possible.' );
is ( $order->{basketno}, $basketno2, 'Regression test Bug 11549: The order still exist in the basket where the transfer has been done.');
$dbh->rollback;
$schema->storage->txn_rollback();

8
t/db_dependent/Acquisition/close_reopen_basket.t

@ -8,12 +8,14 @@ use C4::Biblio qw( AddBiblio DelBiblio );
use C4::Bookseller;
use C4::Budgets;
use C4::Context;
use Koha::Database;
use Koha::Acquisition::Order;
# Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->do(q{
@ -80,4 +82,4 @@ C4::Acquisition::ReopenBasket( $basketno );
is ( scalar( map { $_->{orderstatus} eq 'ordered' ? 1 : () } @orders ), 0, "No order are ordered, the basket is reopen" );
is ( scalar( map { $_->{orderstatus} eq 'new' ? 1 : () } @orders ), 2, "2 orders are new, the basket is reopen" );
$dbh->rollback;
$schema->storage->txn_rollback();

Loading…
Cancel
Save