Bug 22001: Remove the RaiseError occurrences from tests

Unless it is needed!
Also remove $dbh when not used later.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2018-12-14 13:30:52 -03:00 committed by Martin Renvoize
parent dcc9381691
commit 2849b188c8
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
36 changed files with 1 additions and 64 deletions

View File

@ -125,9 +125,6 @@ sub _check_fields_of_orders {
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
# Creating some orders
my $bookseller = Koha::Acquisition::Bookseller->new(
{

View File

@ -36,8 +36,6 @@ use MARC::Record;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };

View File

@ -14,9 +14,6 @@ use Koha::Acquisition::Orders;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $supplier = Koha::Acquisition::Bookseller->new(
{
name => 'my vendor',

View File

@ -14,8 +14,6 @@ use MARC::Record;
#Start transaction
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $bookseller = Koha::Acquisition::Bookseller->new(
{

View File

@ -17,7 +17,6 @@ BEGIN {
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do(q{DELETE FROM aqinvoices});

View File

@ -16,8 +16,6 @@ use t::lib::Mocks;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
my $logged_in_user = $builder->build_object({ class => 'Koha::Patrons' });

View File

@ -17,7 +17,6 @@ my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $curcode = $builder->build({ source => 'Currency' })->{currencycode};

View File

@ -18,9 +18,6 @@ use MARC::Record;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
my $bookseller1 = Koha::Acquisition::Bookseller->new(

View File

@ -16,7 +16,6 @@ my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do(q{
DELETE FROM aqorders;

View File

@ -13,9 +13,6 @@ use t::lib::Mocks;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
my $bookseller_inc_tax = Koha::Acquisition::Bookseller->new(

View File

@ -44,7 +44,6 @@ my $builder = t::lib::TestBuilder->new;
our $cache = Koha::Caches->get_instance;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do("DELETE FROM circulation_rules");

View File

@ -27,9 +27,6 @@ BEGIN {
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
map { $_->delete() } Koha::AudioAlerts->search();
## Check the basics

View File

@ -37,7 +37,6 @@ BEGIN {
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
C4::Context->disable_syspref_cache();
t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost');

View File

@ -37,7 +37,6 @@ my $dbh = C4::Context->dbh;
my $database = Koha::Database->new();
my $schema = $database->schema();
$schema->storage->txn_begin();
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
#Start tests

View File

@ -105,9 +105,6 @@ my $now_value = dt_from_string;
my $mocked_datetime = Test::MockModule->new('DateTime');
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
# Start transaction
$dbh->{RaiseError} = 1;
my $cache = Koha::Caches->get_instance();
$dbh->do(q|DELETE FROM special_holidays|);
$dbh->do(q|DELETE FROM repeatable_holidays|);

View File

@ -35,7 +35,6 @@ my $dbh = $schema->storage->dbh;
my $builder = t::lib::TestBuilder->new();
# Start transaction
$dbh->{RaiseError} = 1;
$schema->storage->txn_begin();
my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };

View File

@ -19,7 +19,6 @@ my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype};

View File

@ -33,8 +33,6 @@ BEGIN {
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
my $itemtype = $builder->build(

View File

@ -35,8 +35,6 @@ my $dbh = C4::Context->dbh;
my $schema = Koha::Database->new()->schema();
my $builder = t::lib::TestBuilder->new;
# Start transaction
$dbh->{RaiseError} = 1;
$schema->storage->txn_begin();
my $now_value = DateTime->now();

View File

@ -41,7 +41,6 @@ my $dbh = C4::Context->dbh;
my $database = Koha::Database->new();
my $schema = $database->schema();
$dbh->{RaiseError} = 1;
sub run_hiding_tests {

View File

@ -33,7 +33,6 @@ my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do("DELETE FROM reserves");
$dbh->do("DELETE FROM old_reserves");

View File

@ -57,8 +57,6 @@ my $column_name = $column_names[0];
ok( column_exists( 'borrowers', $column_name ), 'Known column does exist' );
ok( ! column_exists( 'borrowers', 'xxx'), 'Column xxx does not exist' );
{
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
ok( ! column_exists( 'this_table_will_never_exist', 'xxx'), 'Column xxx does not exist, the table does not exist' );
}
my @constraint_names = $source->unique_constraint_names();

View File

@ -80,8 +80,6 @@ subtest 'General Add, Get and Del tests' => sub {
# Do not modify anything, and do not explode!
my $dbh = C4::Context->dbh;
local $dbh->{RaiseError} = 1;
$getitem->set({})->store;
# Modify item; setting barcode.

View File

@ -26,10 +26,6 @@ use t::lib::TestBuilder;
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
# Start transaction
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new;
my $nb_of_currencies = Koha::Acquisition::Currencies->search->count;

View File

@ -14,7 +14,6 @@ BEGIN {
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
## new() parameter handling check
is(Koha::Misc::Files->new(), undef, "new() param check test/0");

View File

@ -55,7 +55,6 @@ $schema->storage->txn_begin();
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do(q|DELETE FROM letter|);
$dbh->do(q|DELETE FROM message_queue|);

View File

@ -54,7 +54,6 @@ $schema->storage->txn_begin();
my $builder = t::lib::TestBuilder->new();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do(q|DELETE FROM letter|);

View File

@ -44,9 +44,6 @@ use_ok('Koha::Patron::Password::Recovery');
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
#
# Start with fresh data
#

View File

@ -30,11 +30,6 @@ BEGIN {
use_ok('Koha::Patron::Relationships');
}
# Start transaction
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $builder = t::lib::TestBuilder->new();
# Father

View File

@ -264,6 +264,7 @@ subtest 'get_saved_reports' => sub {
defined($errors) && exists($errors->{queryerr}),
'attempting to run a report with an SQL syntax error returns error message (Bug 12214)'
);
$dbh->{RaiseError} = 1;
is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
"get_report_areas returns the correct array of report areas");

View File

@ -7,7 +7,6 @@ use Modern::Perl;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
use C4::Serials::Frequency;

View File

@ -7,7 +7,6 @@ use Koha::Database;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
use C4::Serials::Frequency;
use C4::Serials;

View File

@ -8,7 +8,6 @@ use Koha::Database;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
use C4::Serials::Numberpattern;

View File

@ -29,7 +29,6 @@ my $library2 = $builder->build({
});
my $patron_category = $builder->build({ source => 'Category' });
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my $record = MARC::Record->new();
$record->append_fields(

View File

@ -19,7 +19,6 @@ my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->do(q|DELETE FROM reserves|);
$dbh->do(q|DELETE FROM issues|);

View File

@ -39,8 +39,6 @@ my $borrower;
sub build_test_objects {
$dbh->{RaiseError} = 1;
# Set only to avoid exception.
t::lib::Mocks::mock_preference('dateformat', 'metric');