@@ -, +, @@ --- t/db_dependent/Acquisition.t | 10 ++-------- t/lib/Database.pm | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 t/lib/Database.pm --- a/t/db_dependent/Acquisition.t +++ a/t/db_dependent/Acquisition.t @@ -20,7 +20,7 @@ use Modern::Perl; use POSIX qw(strftime); use Test::More tests => 87; -use Koha::Database; +use t::lib::Database; BEGIN { use_ok('C4::Acquisition'); @@ -118,11 +118,7 @@ sub _check_fields_of_orders { } -my $schema = Koha::Database->new()->schema(); -$schema->storage->txn_begin(); - -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; +my $dbh = t::lib::Database::dbh; # Creating some orders my $booksellerid = C4::Bookseller::AddBookseller( @@ -920,5 +916,3 @@ ok((defined $order4->{datecancellationprinted}), "order is cancelled"); ok(($order4->{cancellationreason} eq "foobar"), "order has cancellation reason \"foobar\""); ok((not defined GetBiblio($order4->{biblionumber})), "biblio does not exist anymore"); # End of tests for DelOrder - -$schema->storage->txn_rollback(); --- a/t/lib/Database.pm +++ a/t/lib/Database.pm @@ -0,0 +1,19 @@ +package t::lib::Database; + +use C4::Context; +use Koha::Database; + +sub dbh { + my $dbh = C4::Context->dbh; + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + $dbh->{RaiseError} = 1; + return $dbh; +} + +END { + my $schema = Koha::Database->new->schema; + $schema->storage->txn_rollback; +}; + +1; --