@@ -, +, @@ --- t/db_dependent/Acquisition/FillWithDefaultValues.t | 6 +++--- t/db_dependent/AdditionalField.t | 8 +++----- t/db_dependent/Auth_with_cas.t | 11 +++-------- t/db_dependent/BackgroundJob.t | 8 ++++---- t/db_dependent/Charset.t | 8 ++++---- t/db_dependent/Circulation/CheckIfIssuedToPatron.t | 8 +------- t/db_dependent/Circulation/CheckValidBarcode.t | 8 +++----- t/db_dependent/Circulation/GetHardDueDate.t | 9 +++------ t/db_dependent/Circulation/OfflineOperation.t | 9 +++------ t/db_dependent/ColumnsSettings.t | 8 ++++---- t/db_dependent/Contract.t | 7 +++---- t/db_dependent/Fines.t | 7 ++----- t/db_dependent/Koha/GetDailyQuote.t | 9 +++------ t/db_dependent/Koha/Item/Search/Field.t | 7 +++---- t/db_dependent/Koha_Misc_Files.t | 8 +++----- t/db_dependent/Labels/t_Batch.t | 8 +++----- t/db_dependent/Languages.t | 10 ++++------ t/db_dependent/Letters/GetLetterTemplates.t | 5 +++-- t/db_dependent/Letters/GetLettersAvailableForALibrary.t | 5 +++-- t/db_dependent/LibraryGroups.t | 7 ++++--- t/db_dependent/MarcModificationTemplates.t | 5 +++-- t/db_dependent/MungeMarcPrice.t | 13 ++++--------- t/db_dependent/NewsChannels.t | 9 +++------ t/db_dependent/Overdues.t | 5 +++-- t/db_dependent/Record.t | 7 +++---- t/db_dependent/Record/marcrecord2csv.t | 5 +++-- t/db_dependent/RotatingCollections.t | 10 +++------- t/db_dependent/Serials.t | 10 +++------- t/db_dependent/Serials/Claims.t | 5 +++-- t/db_dependent/Serials/Frequency.t | 7 +++---- t/db_dependent/Serials/GetNextSeq.t | 8 +++----- t/db_dependent/Serials/Numberpattern.t | 12 ++++++------ t/db_dependent/Stats.t | 9 +++------ t/db_dependent/Virtualshelves.t | 4 +++- t/db_dependent/XISBN.t | 8 +++----- t/db_dependent/sysprefs.t | 8 +++----- 36 files changed, 114 insertions(+), 167 deletions(-) --- a/t/db_dependent/Acquisition/FillWithDefaultValues.t +++ a/t/db_dependent/Acquisition/FillWithDefaultValues.t @@ -7,10 +7,10 @@ use MARC::Field; use C4::Context; use C4::Acquisition qw( FillWithDefaultValues ); +use Koha::Database; -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $biblio_module = Test::MockModule->new('C4::Biblio'); my $default_author = 'default author'; --- a/t/db_dependent/AdditionalField.t +++ a/t/db_dependent/AdditionalField.t @@ -5,10 +5,11 @@ use Test::More tests => 40; use C4::Context; use Koha::AdditionalField; +use Koha::Database; +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 additional_fields| ); $dbh->do( q|DELETE FROM additional_field_values| ); @@ -290,6 +291,3 @@ is_deeply ( $af1->values, {$subscriptionid2 => qq|value_for_af1_$subscriptionid2 $af1->delete_values; $af1->fetch_values; is_deeply ( $af1->values, {}, "fetch_values: no values" ); - - -$dbh->rollback; --- a/t/db_dependent/Auth_with_cas.t +++ a/t/db_dependent/Auth_with_cas.t @@ -22,6 +22,7 @@ use CGI; use t::lib::Mocks; use C4::Context; +use Koha::Database; BEGIN { use_ok('C4::Auth_with_cas'); @@ -34,10 +35,9 @@ BEGIN { /); } +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -# Start transaction -$dbh->{ AutoCommit } = 0; -$dbh->{ RaiseError } = 1; C4::Context->disable_syspref_cache(); t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost'); @@ -63,8 +63,3 @@ $ENV{SCRIPT_NAME} = '/cgi-bin/koha/circ/circulation-home.pl'; is(C4::Auth_with_cas::_url_with_get_params($cgi, 'intranet'), "$staff_base_url/cgi-bin/koha/circ/circulation-home.pl?bar=baz", "Intranet URL should be returned when using intranet login (Bug 13507)"); - - - -$dbh->rollback; - --- a/t/db_dependent/BackgroundJob.t +++ a/t/db_dependent/BackgroundJob.t @@ -5,15 +5,15 @@ use C4::Auth; use CGI qw ( -utf8 ); use Test::More tests => 18; +use Koha::Database; + BEGIN { use_ok('C4::BackgroundJob'); } my $query = new CGI; -# Generate a session id -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $session = C4::Auth::get_session; $session->flush; --- a/t/db_dependent/Charset.t +++ a/t/db_dependent/Charset.t @@ -6,9 +6,11 @@ use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); use C4::Context; use C4::Charset qw( SanitizeRecord ); +use Koha::Database; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; my $frameworkcode = q||; @@ -47,5 +49,3 @@ $record->append_fields( ( $sanitized_record, $has_been_modified ) = C4::Charset::SanitizeRecord( $record, $biblionumber ); is( $has_been_modified, 1, 'SanitizeRecord: the record has been modified' ); is( $url, $sanitized_record->subfield($url_field, $url_subfield), 'SanitizeRecord: the url has not been modified'); - -$dbh->rollback; --- a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t +++ a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t @@ -30,13 +30,10 @@ use MARC::Record; my $schema = Koha::Database->schema; $schema->storage->txn_begin; +my $dbh = C4::Context->dbh; my $builder = t::lib::TestBuilder->new; -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; - $dbh->do(q|DELETE FROM issues|); $dbh->do(q|DELETE FROM items|); $dbh->do(q|DELETE FROM borrowers|); @@ -125,6 +122,3 @@ $check_if_issued = C4::Circulation::CheckIfIssuedToPatron($borrowernumber2, $bib is( $check_if_issued, undef, 'CheckIfIssuedToPatron returns undef' ); $check_if_issued = C4::Circulation::CheckIfIssuedToPatron($borrowernumber2, $biblionumber2); is( $check_if_issued, 1, 'CheckIfIssuedToPatron returns true' ); - -$dbh->rollback(); - --- a/t/db_dependent/Circulation/CheckValidBarcode.t +++ a/t/db_dependent/Circulation/CheckValidBarcode.t @@ -22,6 +22,7 @@ use Test::More tests => 10; use C4::Circulation; use C4::Biblio; use C4::Items; +use Koha::Database; use Koha::Library; @@ -29,9 +30,9 @@ BEGIN { use_ok('C4::Circulation'); } +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 issues|); $dbh->do(q|DELETE FROM items|); @@ -81,6 +82,3 @@ $check_valid_barcode = C4::Circulation::CheckValidBarcode($barcode3); is( $check_valid_barcode, 1, 'CheckValidBarcode returns true' ); $check_valid_barcode = C4::Circulation::CheckValidBarcode('wrong barcode'); is( $check_valid_barcode, 0, 'CheckValidBarcode with an invalid barcode returns false' ); - -$dbh->rollback(); - --- a/t/db_dependent/Circulation/GetHardDueDate.t +++ a/t/db_dependent/Circulation/GetHardDueDate.t @@ -3,6 +3,7 @@ use Modern::Perl; use C4::Context; use DateTime; +use Koha::Database; use Koha::DateUtils; use Koha::IssuingRules; use Koha::Library; @@ -20,10 +21,9 @@ can_ok( ) ); -#Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; $dbh->do(q|DELETE FROM issues|); $dbh->do(q|DELETE FROM items|); @@ -397,6 +397,3 @@ is_deeply( ], "GetHardDueDate returns the duedate and the duedatecompare" ); - -#End transaction -$dbh->rollback; --- a/t/db_dependent/Circulation/OfflineOperation.t +++ a/t/db_dependent/Circulation/OfflineOperation.t @@ -3,6 +3,7 @@ use Modern::Perl; use C4::Circulation; +use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Library; @@ -21,10 +22,9 @@ can_ok( ) ); -#Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; $dbh->do(q|DELETE FROM issues|); $dbh->do(q|DELETE FROM borrowers|); @@ -99,6 +99,3 @@ is( DeleteOfflineOperation($offline_id), #is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef'); #is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME - -#End transaction -$dbh->rollback; --- a/t/db_dependent/ColumnsSettings.t +++ a/t/db_dependent/ColumnsSettings.t @@ -6,9 +6,11 @@ use Test::MockModule; use C4::Context; use C4::Utils::DataTables::ColumnsSettings; +use Koha::Database; + +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 columns_settings|); @@ -180,5 +182,3 @@ for my $m ( keys %$modules ) { } } } - -$dbh->rollback; --- a/t/db_dependent/Contract.t +++ a/t/db_dependent/Contract.t @@ -20,6 +20,7 @@ use Modern::Perl; use C4::Context; +use Koha::Database; use Koha::DateUtils; use Koha::Acquisition::Booksellers; @@ -31,9 +32,9 @@ BEGIN { use_ok('C4::Contract'); } +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 aqbasket|); $dbh->do(q|DELETE FROM aqcontract|); @@ -148,5 +149,3 @@ $del_status = DelContract( { contractnumber => $my_contract_id2 } ); is( $del_status, 1, 'DelContract returns true' ); $contracts = GetContracts(); is( @$contracts, 0, 'DelContract deletes a contract' ); - -$dbh->rollback; --- a/t/db_dependent/Fines.t +++ a/t/db_dependent/Fines.t @@ -9,12 +9,9 @@ use Koha::DateUtils; use Test::More tests => 5; -#Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -my $schema = Koha::Database->new()->schema(); - -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; $dbh->do(q|DELETE FROM issuingrules|); --- a/t/db_dependent/Koha/GetDailyQuote.t +++ a/t/db_dependent/Koha/GetDailyQuote.t @@ -21,6 +21,7 @@ use Test::More tests => 12; use C4::Koha qw( GetDailyQuote ); use DateTime::Format::MySQL; +use Koha::Database; use Koha::DateUtils qw(dt_from_string); BEGIN { @@ -29,12 +30,10 @@ BEGIN { can_ok('C4::Koha', qw( GetDailyQuote )); +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -# Start transaction -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; - # Setup stage $dbh->do("DELETE FROM quotes"); @@ -83,5 +82,3 @@ $dbh->do(q|INSERT INTO `quotes` VALUES $quote = GetDailyQuote(); is( $quote->{id}, 6, ' GetDailyQuote returns the only existing quote' ); - -$dbh->rollback; --- a/t/db_dependent/Koha/Item/Search/Field.t +++ a/t/db_dependent/Koha/Item/Search/Field.t @@ -4,13 +4,14 @@ use Modern::Perl; use Test::More tests => 11; use C4::Context; +use Koha::Database; use_ok('Koha::Item::Search::Field'); import Koha::Item::Search::Field qw(AddItemSearchField ModItemSearchField DelItemSearchField GetItemSearchField GetItemSearchFields); -my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; # Start with empty table. foreach my $field (GetItemSearchFields()) { @@ -35,5 +36,3 @@ is_deeply($field, {name => 'foo', label => 'Foo', tagfield => '001', tagsubfield ok((defined ModItemSearchField({name => 'foo', label => 'Foobar', tagfield => '100', 'tagsubfield' => 'a'})), "successful mod"); $field = GetItemSearchField('foo'); is_deeply($field, {name => 'foo', label => 'Foobar', tagfield => '100', tagsubfield => 'a', authorised_values_category => undef}); - -$dbh->rollback; --- a/t/db_dependent/Koha_Misc_Files.t +++ a/t/db_dependent/Koha_Misc_Files.t @@ -5,15 +5,16 @@ use Modern::Perl; use C4::Context; +use Koha::Database; use Test::More tests => 30; BEGIN { use_ok('Koha::Misc::Files'); } +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; ## new() parameter handling check is(Koha::Misc::Files->new(), undef, "new() param check test/0"); @@ -84,6 +85,3 @@ is(scalar @$files_a_123_infos, 0, "GetFilesInfo() result count after DelAllFiles my $number_of_deleted_files_b_221 = $mf_b_221->DelAllFiles(); is( $number_of_deleted_files_b_221, 1, "DelAllFiles returns the number of deleted files/2" ); is(scalar @{$mf_b_221->GetFilesInfo()}, 0, "GetFilesInfo() result count after DelAllFiles()/2"); - -$dbh->rollback; - --- a/t/db_dependent/Labels/t_Batch.t +++ a/t/db_dependent/Labels/t_Batch.t @@ -29,16 +29,16 @@ use t::lib::TestBuilder; use C4::Context; use C4::Items; use C4::Biblio; +use Koha::Database; use Koha::Libraries; BEGIN { use_ok('C4::Labels::Batch'); } -# Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; my $builder = t::lib::TestBuilder->new; $builder->build({ source => 'Branch', value => { branchcode => 'CPL' } }) @@ -120,5 +120,3 @@ is_deeply($updated_batch, $batch, "Updated batch object is correct."); # Testing Batch->delete() method. my $del_results = $batch->delete(); ok($del_results eq 0, "Batch->delete() success."); - -$dbh->rollback; --- a/t/db_dependent/Languages.t +++ a/t/db_dependent/Languages.t @@ -3,22 +3,22 @@ # This Koha test module is a stub! # Add more tests here!!! -use strict; -use warnings; +use Modern::Perl; use Test::More tests => 17; use List::Util qw(first); use Data::Dumper; use Test::Warn; use t::lib::Mocks; +use Koha::Database; BEGIN { use_ok('C4::Languages'); } +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; isnt(C4::Languages::_get_themes(), undef, 'testing _get_themes doesnt return undef'); @@ -94,5 +94,3 @@ $sth->execute(); my $LangRfc4646 = $sth->fetchall_arrayref({}); is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates."); - -$dbh->rollback; --- a/t/db_dependent/Letters/GetLetterTemplates.t +++ a/t/db_dependent/Letters/GetLetterTemplates.t @@ -3,10 +3,11 @@ use Test::More tests => 7; use C4::Context; use C4::Letters qw( GetLetterTemplates ); +use Koha::Database; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; $dbh->do(q|DELETE FROM letter|); --- a/t/db_dependent/Letters/GetLettersAvailableForALibrary.t +++ a/t/db_dependent/Letters/GetLettersAvailableForALibrary.t @@ -3,10 +3,11 @@ use Test::More tests => 19; use C4::Context; use C4::Letters qw( GetLettersAvailableForALibrary DelLetter ); +use Koha::Database; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; $dbh->do(q|DELETE FROM letter|); --- a/t/db_dependent/LibraryGroups.t +++ a/t/db_dependent/LibraryGroups.t @@ -7,6 +7,7 @@ use List::MoreUtils 'any'; use Test::More tests => 20; use t::lib::TestBuilder; +use Koha::Database; BEGIN { use FindBin; @@ -15,9 +16,9 @@ BEGIN { use_ok('Koha::Library::Groups'); } -our $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; +my $dbh = C4::Context->dbh; $dbh->do(q|DELETE FROM issues|); $dbh->do(q|DELETE FROM library_groups|); --- a/t/db_dependent/MarcModificationTemplates.t +++ a/t/db_dependent/MarcModificationTemplates.t @@ -2,15 +2,16 @@ use Modern::Perl; use Test::More tests => 115; +use Koha::Database; use Koha::SimpleMARC; use_ok("MARC::Field"); use_ok("MARC::Record"); use_ok("C4::MarcModificationTemplates"); +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 marc_modification_templates|); --- a/t/db_dependent/MungeMarcPrice.t +++ a/t/db_dependent/MungeMarcPrice.t @@ -1,20 +1,18 @@ #!/usr/bin/perl -use strict; -use warnings; +use Modern::Perl; use C4::Biblio; +use Koha::Database; use Koha::Acquisition::Currencies; use Test::More; -use utf8; # work around wide character warnings binmode Test::More->builder->output, ":encoding(UTF-8)"; binmode Test::More->builder->failure_output, ":encoding(UTF-8)"; -# start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; # set some test price strings and expected output my @prices2test=( { string => '25,5 £, $34,55, $LD35', expected => '34.55' }, @@ -69,6 +67,3 @@ foreach my $price (@prices2test) { "got expected price from $price->{'string'} (using ISO code as currency name)", ); } - -# Cleanup -$dbh->rollback; --- a/t/db_dependent/NewsChannels.t +++ a/t/db_dependent/NewsChannels.t @@ -1,6 +1,7 @@ #!/usr/bin/perl use Modern::Perl; +use Koha::Database; use Koha::DateUtils; use Koha::Libraries; @@ -10,12 +11,10 @@ BEGIN { use_ok('C4::NewsChannels'); } +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -# Start transaction -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; - # Add LIB1, if it doesn't exist. my $addbra = 'LIB1'; unless ( Koha::Libraries->find($addbra) ) { @@ -226,5 +225,3 @@ subtest 'Regression tests on author title, firstname, and surname.', sub { ok($check==3,'Both with and without author data tested'); done_testing(); }; - -$dbh->rollback; --- a/t/db_dependent/Overdues.t +++ a/t/db_dependent/Overdues.t @@ -4,14 +4,15 @@ use Modern::Perl; use Test::More tests => 16; use C4::Context; +use Koha::Database; use Koha::Libraries; use_ok('C4::Overdues'); can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes'); can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules'); +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 letter|); $dbh->do(q|DELETE FROM message_queue|); --- a/t/db_dependent/Record.t +++ a/t/db_dependent/Record.t @@ -7,15 +7,14 @@ use MARC::Record; use t::lib::Mocks; use C4::Context; +use Koha::Database; BEGIN { use_ok('C4::Record'); } -my $dbh = C4::Context->dbh; -# Start transaction -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} ); --- a/t/db_dependent/Record/marcrecord2csv.t +++ a/t/db_dependent/Record/marcrecord2csv.t @@ -10,12 +10,13 @@ use Text::CSV::Encoded; use C4::Biblio qw( AddBiblio ); use C4::Context; use C4::Record; +use Koha::Database; use t::lib::TestBuilder; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; my $builder = t::lib::TestBuilder->new; my $module_biblio = Test::MockModule->new('C4::Biblio'); --- a/t/db_dependent/RotatingCollections.t +++ a/t/db_dependent/RotatingCollections.t @@ -21,6 +21,7 @@ use Test::More tests => 51; use C4::Context; use C4::RotatingCollections; use C4::Biblio; +use Koha::Database; use Koha::Library; BEGIN { @@ -44,10 +45,9 @@ can_ok( ) ); -#Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; #Start Tests $dbh->do(q|DELETE FROM issues |); @@ -330,7 +330,3 @@ is( $countcollection + 1, "Two Collections have been deleted" ); - -#End transaction -$dbh->rollback; - --- a/t/db_dependent/Serials.t +++ a/t/db_dependent/Serials.t @@ -6,7 +6,6 @@ use Modern::Perl; use YAML; -use CGI qw ( -utf8 ); use C4::Serials; use C4::Serials::Frequency; use C4::Serials::Numberpattern; @@ -14,6 +13,7 @@ use C4::Debug; use C4::Biblio; use C4::Budgets; use C4::Items; +use Koha::Database; use Koha::DateUtils; use Koha::Acquisition::Booksellers; use t::lib::Mocks; @@ -24,12 +24,10 @@ BEGIN { use_ok('C4::Serials'); } +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -# Start transaction -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; - my $builder = t::lib::TestBuilder->new(); # This could/should be used for all untested methods @@ -348,8 +346,6 @@ subtest "Do not generate an expected if one already exists" => sub { is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); }; -$dbh->rollback; - sub get_biblio { my $bib = MARC::Record->new(); $bib->append_fields( --- a/t/db_dependent/Serials/Claims.t +++ a/t/db_dependent/Serials/Claims.t @@ -3,14 +3,15 @@ use Test::More tests => 17; use C4::Acquisition; use C4::Budgets; +use Koha::Database; use Koha::Acquisition::Booksellers; use_ok('C4::Serials'); use Koha::DateUtils qw( dt_from_string output_pref ); +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 issues|); $dbh->do(q|DELETE FROM subscription|); --- a/t/db_dependent/Serials/Frequency.t +++ a/t/db_dependent/Serials/Frequency.t @@ -1,12 +1,13 @@ #!/usr/bin/perl use C4::Context; +use Koha::Database; use Test::More tests => 27; use Modern::Perl; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; use C4::Serials::Frequency; @@ -86,5 +87,3 @@ is(scalar @frequencies, 1, "There is one frequency"); DelSubscriptionFrequency($id2); @frequencies = GetSubscriptionFrequencies(); is(scalar @frequencies, 0, "There is no frequency"); - -$dbh->rollback; --- a/t/db_dependent/Serials/GetNextSeq.t +++ a/t/db_dependent/Serials/GetNextSeq.t @@ -3,10 +3,11 @@ use C4::Context; use Test::More tests => 32; use Modern::Perl; +use Koha::Database; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; use C4::Serials::Frequency; use C4::Serials; @@ -264,9 +265,6 @@ $publisheddate = GetNextDate($subscription, $publisheddate); $seq = _next_seq($subscription, $pattern, $publisheddate); is($seq, 'Z: 4, Y: 5, X: 1'); - -$dbh->rollback; - sub _next_seq { my ($subscription, $pattern, $publisheddate) = @_; my $seq; --- a/t/db_dependent/Serials/Numberpattern.t +++ a/t/db_dependent/Serials/Numberpattern.t @@ -1,12 +1,14 @@ #!/usr/bin/perl -use C4::Context; -use Test::More tests => 95; use Modern::Perl; +use Test::More tests => 95; +use C4::Context; +use Koha::Database; + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; use C4::Serials::Numberpattern; @@ -99,5 +101,3 @@ is(scalar @numberpatterns, 1, "There is one numberpattern"); DelSubscriptionNumberpattern($id2); @numberpatterns = GetSubscriptionNumberpatterns(); is(scalar @numberpatterns, 0, "There is no numberpattern"); - -$dbh->rollback; --- a/t/db_dependent/Stats.t +++ a/t/db_dependent/Stats.t @@ -2,6 +2,7 @@ use Modern::Perl; use C4::Stats; +use Koha::Database; use Test::More tests => 19; @@ -13,10 +14,9 @@ can_ok( qw(UpdateStats) ); -#Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; # # Test UpdateStats @@ -163,6 +163,3 @@ is( $line->{location}, undef, "UpdateStats sets location to NULL if undef is passed in." ); # More tests to write! - -#End transaction -$dbh->rollback; --- a/t/db_dependent/Virtualshelves.t +++ a/t/db_dependent/Virtualshelves.t @@ -5,6 +5,7 @@ use Test::More tests => 6; use DateTime::Duration; use C4::Context; +use Koha::Database; use Koha::DateUtils; use Koha::Virtualshelves; use Koha::Virtualshelfshares; @@ -15,8 +16,9 @@ use t::lib::TestBuilder; my $builder = t::lib::TestBuilder->new; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; teardown(); subtest 'CRUD' => sub { --- a/t/db_dependent/XISBN.t +++ a/t/db_dependent/XISBN.t @@ -11,6 +11,7 @@ use C4::Biblio; use C4::XISBN; use C4::Context; use C4::Search; +use Koha::Database; use t::lib::Mocks; use Test::MockModule; @@ -18,9 +19,8 @@ BEGIN { use_ok('C4::XISBN'); } -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $search_module = new Test::MockModule('C4::Search'); @@ -62,8 +62,6 @@ SKIP: { "Gets correct biblionumber from a book with a similar isbn using ThingISBN." ); } -$dbh->rollback; - # Util subs # Add new biblio with isbn and return biblionumber --- a/t/db_dependent/sysprefs.t +++ a/t/db_dependent/sysprefs.t @@ -21,11 +21,11 @@ use Modern::Perl; use Test::More tests => 8; use C4::Context; +use Koha::Database; -# Start transaction +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; -$dbh->{AutoCommit} = 0; my $opacheader = C4::Context->preference('opacheader'); my $newopacheader = "newopacheader"; @@ -59,5 +59,3 @@ $dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'"); is(C4::Context->preference('testpreference'), 'def', 'caching preferences'); C4::Context->clear_syspref_cache(); is(C4::Context->preference('testpreference'), undef, 'clearing preference cache'); - -$dbh->rollback; --