[Koha-patches] [PATCH] Bug 11213: Fix mixing Koha::Database and C4::Context->dbh in test
Srdjan
srdjan at catalyst.net.nz
Mon Sep 7 08:16:00 CEST 2015
---
t/db_dependent/Items.t | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t
index 5fed5a3..d621f62 100755
--- a/t/db_dependent/Items.t
+++ b/t/db_dependent/Items.t
@@ -32,6 +32,7 @@ BEGIN {
}
my $dbh = C4::Context->dbh;
+$dbh->{RaiseError} = 1;
my $branches = GetBranches;
my ($branch1, $branch2) = keys %$branches;
@@ -40,8 +41,7 @@ subtest 'General Add, Get and Del tests' => sub {
plan tests => 10;
# Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ local $dbh->{AutoCommit} = 0;
# Create a biblio instance for testing
C4::Context->set_preference('marcflavour', 'MARC21');
@@ -92,8 +92,7 @@ subtest 'GetHiddenItemnumbers tests' => sub {
# This sub is controlled by the OpacHiddenItems system preference.
# Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ local $dbh->{AutoCommit} = 0;
# Create a new biblio
C4::Context->set_preference('marcflavour', 'MARC21');
@@ -177,8 +176,7 @@ subtest 'GetItemsInfo tests' => sub {
plan tests => 4;
# Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ local $dbh->{AutoCommit} = 0;
# Add a biblio
my ($biblionumber, $biblioitemnumber) = get_biblio();
@@ -213,11 +211,8 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
plan tests => 2;
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
-
my $schema = Koha::Database->new()->schema();
+ $schema->txn_begin;
my $biblio =
$schema->resultset('Biblio')->create(
@@ -240,16 +235,13 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
C4::Context->set_preference( 'item-level_itypes', 1 );
ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is enabled' );
-
- $dbh->rollback;
};
subtest 'SearchItems test' => sub {
plan tests => 14;
# Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ local $dbh->{AutoCommit} = 0;
C4::Context->set_preference('marcflavour', 'MARC21');
my ($biblionumber) = get_biblio();
@@ -413,7 +405,6 @@ subtest 'Koha::Item(s) tests' => sub {
# Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
- $dbh->{RaiseError} = 1;
# Create a biblio and item for testing
C4::Context->set_preference('marcflavour', 'MARC21');
--
1.9.1
More information about the Koha-patches
mailing list