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';
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| );
$af1->delete_values;
$af1->fetch_values;
is_deeply ( $af1->values, {}, "fetch_values: no values" );
-
-
-$dbh->rollback;
use t::lib::Mocks;
use C4::Context;
+use Koha::Database;
BEGIN {
use_ok('C4::Auth_with_cas');
/);
}
+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');
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;
-
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;
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||;
( $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;
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|);
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();
-
use C4::Circulation;
use C4::Biblio;
use C4::Items;
+use Koha::Database;
use Koha::Library;
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|);
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();
-
use Modern::Perl;
use C4::Context;
use DateTime;
+use Koha::Database;
use Koha::DateUtils;
use Koha::IssuingRules;
use Koha::Library;
)
);
-#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|);
],
"GetHardDueDate returns the duedate and the duedatecompare"
);
-
-#End transaction
-$dbh->rollback;
use Modern::Perl;
use C4::Circulation;
+use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Library;
)
);
-#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|);
#is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
#is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
-
-#End transaction
-$dbh->rollback;
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|);
}
}
}
-
-$dbh->rollback;
use Modern::Perl;
use C4::Context;
+use Koha::Database;
use Koha::DateUtils;
use Koha::Acquisition::Booksellers;
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|);
is( $del_status, 1, 'DelContract returns true' );
$contracts = GetContracts();
is( @$contracts, 0, 'DelContract deletes a contract' );
-
-$dbh->rollback;
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|);
use C4::Koha qw( GetDailyQuote );
use DateTime::Format::MySQL;
+use Koha::Database;
use Koha::DateUtils qw(dt_from_string);
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");
$quote = GetDailyQuote();
is( $quote->{id}, 6, ' GetDailyQuote returns the only existing quote' );
-
-$dbh->rollback;
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()) {
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;
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");
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;
-
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' } })
# Testing Batch->delete() method.
my $del_results = $batch->delete();
ok($del_results eq 0, "Batch->delete() success.");
-
-$dbh->rollback;
# 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');
my $LangRfc4646 = $sth->fetchall_arrayref({});
is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates.");
-
-$dbh->rollback;
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|);
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|);
use Test::More tests => 20;
use t::lib::TestBuilder;
+use Koha::Database;
BEGIN {
use FindBin;
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|);
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|);
#!/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' },
"got expected price from $price->{'string'} (using ISO code as currency name)",
);
}
-
-# Cleanup
-$dbh->rollback;
#!/usr/bin/perl
use Modern::Perl;
+use Koha::Database;
use Koha::DateUtils;
use Koha::Libraries;
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) ) {
ok($check==3,'Both with and without author data tested');
done_testing();
};
-
-$dbh->rollback;
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|);
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{} );
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');
use C4::Context;
use C4::RotatingCollections;
use C4::Biblio;
+use Koha::Database;
use Koha::Library;
BEGIN {
)
);
-#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 |);
$countcollection + 1,
"Two Collections have been deleted"
);
-
-#End transaction
-$dbh->rollback;
-
use Modern::Perl;
use YAML;
-use CGI qw ( -utf8 );
use C4::Serials;
use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
use C4::Biblio;
use C4::Budgets;
use C4::Items;
+use Koha::Database;
use Koha::DateUtils;
use Koha::Acquisition::Booksellers;
use t::lib::Mocks;
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
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(
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|);
#!/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;
DelSubscriptionFrequency($id2);
@frequencies = GetSubscriptionFrequencies();
is(scalar @frequencies, 0, "There is no frequency");
-
-$dbh->rollback;
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;
$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;
#!/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;
DelSubscriptionNumberpattern($id2);
@numberpatterns = GetSubscriptionNumberpatterns();
is(scalar @numberpatterns, 0, "There is no numberpattern");
-
-$dbh->rollback;
use Modern::Perl;
use C4::Stats;
+use Koha::Database;
use Test::More tests => 19;
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
"UpdateStats sets location to NULL if undef is passed in." );
# More tests to write!
-
-#End transaction
-$dbh->rollback;
use DateTime::Duration;
use C4::Context;
+use Koha::Database;
use Koha::DateUtils;
use Koha::Virtualshelves;
use Koha::Virtualshelfshares;
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 {
use C4::XISBN;
use C4::Context;
use C4::Search;
+use Koha::Database;
use t::lib::Mocks;
use Test::MockModule;
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');
"Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
}
-$dbh->rollback;
-
# Util subs
# Add new biblio with isbn and return biblionumber
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";
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
C4::Context->clear_syspref_cache();
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
-
-$dbh->rollback;