use_ok('Koha::Borrower');
}
-# Start transaction
-my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
-my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
-my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
+my $categorycode = $schema->resultset('Category')->first()->categorycode();
+my $branchcode = $schema->resultset('Branch')->first()->branchcode();
my $object = Koha::Borrower->new();
my $borrowernumber = $object->borrowernumber;
-my $borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
+my $borrower = $schema->resultset('Borrower')->find( $borrowernumber );
is( $borrower->surname(), "Test Surname", "Object found in database" );
is( $object->is_changed(), 0, "Object is unchanged" );
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
$object->delete();
-$borrower = Koha::Database->new()->schema()->resultset('Borrower')->find( $borrowernumber );
+$borrower = $schema->resultset('Borrower')->find( $borrowernumber );
ok( ! $borrower, "Object no longer found in database" );
is( $object->in_storage, 0, "Object is not in storage" );
use_ok('Koha::Items');
}
-my $dbh = C4::Context->dbh;
+my $schema = Koha::Database->new->schema;
+
my $branches = GetBranches;
my ($branch1, $branch2) = keys %$branches;
my $location = 'My Location';
plan tests => 14;
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin;
# Create a biblio instance for testing
C4::Context->set_preference('marcflavour', 'MARC21');
is( $getitem->{location}, 'CART', "The location should have been set to CART" );
is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" );
- $dbh->rollback;
+ $schema->storage->txn_rollback;
};
subtest 'GetHiddenItemnumbers tests' => sub {
# This sub is controlled by the OpacHiddenItems system preference.
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin;
# Create a new biblio
C4::Context->set_preference('marcflavour', 'MARC21');
@hidden = GetHiddenItemnumbers( @items );
ok( scalar @hidden == 0, "Empty items list, no item hidden");
- $dbh->rollback;
+ $schema->storage->txn_rollback;
};
subtest 'GetItemsInfo tests' => sub {
plan tests => 4;
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin;
# Add a biblio
my ($biblionumber, $biblioitemnumber) = get_biblio();
is( exists( $results[0]->{ onsite_checkout } ), 1,
'GetItemsInfo returns a onsite_checkout key' );
- $dbh->rollback;
+ $schema->storage->txn_rollback;
};
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
plan tests => 4;
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin;
my $schema = Koha::Database->new()->schema();
$effective_itemtype eq 'BIB_LEVEL',
'$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' );
- $dbh->rollback;
+ $schema->storage->txn_rollback;
};
subtest 'SearchItems test' => sub {
plan tests => 14;
- # Start transaction
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin;
+ my $dbh = C4::Context->dbh;
C4::Context->set_preference('marcflavour', 'MARC21');
my $cpl_items_before = SearchItemsByField( 'homebranch', 'CPL');
my $cpl_items_after = SearchItemsByField( 'homebranch', 'CPL');
is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItemsByField should return something' );
- $dbh->rollback;
+ $schema->storage->txn_rollback;
};
subtest 'Koha::Item(s) tests' => sub {
plan tests => 5;
- # 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');
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
plan tests => 7;
- $dbh->{AutoCommit} = 0;
- $dbh->{RaiseError} = 1;
+ $schema->storage->txn_begin();
my ( $biblionumber, $biblioitemnumber ) = get_biblio();
my $item_infos = [
use Test::Warn;
use C4::Context;
+use Koha::Database;
BEGIN {
use_ok('C4::Reports::Guided');
qw(save_report delete_report execute_query)
);
-#Start transaction
-my $dbh = C4::Context->dbh;
-$dbh->{RaiseError} = 1;
-$dbh->{AutoCommit} = 0;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+my $dbh = C4::Context->dbh;
$dbh->do(q|DELETE FROM saved_sql|);
$dbh->do(q|DELETE FROM saved_reports|);
is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
"get_report_areas returns the correct array of report areas");
-#End transaction
-$dbh->rollback;
-
+$schema->storage->txn_rollback;