From 9698174fcd759657ef23aa11753c78b618723032 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 14 Dec 2018 13:30:52 -0300 Subject: [PATCH] Bug 22001: Remove the RaiseError occurrences from tests Unless it is needed! Also remove $dbh when not used later. --- t/db_dependent/Acquisition.t | 3 --- t/db_dependent/Acquisition/CancelReceipt.t | 2 -- t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t | 3 --- t/db_dependent/Acquisition/GetOrdersByBiblionumber.t | 2 -- t/db_dependent/Acquisition/Invoices.t | 1 - t/db_dependent/Acquisition/NewOrder.t | 2 -- t/db_dependent/Acquisition/OrderFromSubscription.t | 1 - t/db_dependent/Acquisition/TransferOrder.t | 3 --- t/db_dependent/Acquisition/close_reopen_basket.t | 1 - t/db_dependent/Acquisition/populate_order_with_prices.t | 3 --- t/db_dependent/ArticleRequests.t | 1 - t/db_dependent/AudioAlerts.t | 3 --- t/db_dependent/Auth_with_cas.t | 1 - t/db_dependent/Bookseller.t | 1 - t/db_dependent/Circulation.t | 3 --- t/db_dependent/Circulation/GetTopIssues.t | 1 - t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t | 1 - t/db_dependent/CourseReserves.t | 2 -- t/db_dependent/DecreaseLoanHighHolds.t | 2 -- t/db_dependent/Filter_MARC_ViewPolicy.t | 1 - t/db_dependent/Holds/RevertWaitingStatus.t | 1 - t/db_dependent/Installer.t | 2 -- t/db_dependent/Items.t | 2 -- t/db_dependent/Koha/Acquisition/Currencies.t | 4 ---- t/db_dependent/Koha_Misc_Files.t | 1 - t/db_dependent/Letters.t | 1 - t/db_dependent/Letters/TemplateToolkit.t | 1 - t/db_dependent/Members/Attributes.t | 1 - t/db_dependent/Passwordrecovery.t | 3 --- t/db_dependent/Patron/Relationships.t | 5 ----- t/db_dependent/Reports/Guided.t | 1 + t/db_dependent/Serials/Frequency.t | 1 - t/db_dependent/Serials/GetNextSeq.t | 1 - t/db_dependent/Serials/Numberpattern.t | 1 - t/db_dependent/Serials_2.t | 1 - t/db_dependent/ShelfBrowser.t | 1 - t/db_dependent/cronjobs/advance_notices_digest.t | 2 -- 37 files changed, 1 insertion(+), 65 deletions(-) diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index a367aa8987..e80c0f5194 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -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( { diff --git a/t/db_dependent/Acquisition/CancelReceipt.t b/t/db_dependent/Acquisition/CancelReceipt.t index f659e9ef3a..f26e4b6f3a 100644 --- a/t/db_dependent/Acquisition/CancelReceipt.t +++ b/t/db_dependent/Acquisition/CancelReceipt.t @@ -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 }; diff --git a/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t b/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t index 267ff107c6..ec8fceb378 100644 --- a/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t +++ b/t/db_dependent/Acquisition/GetBasketsInfosByBookseller.t @@ -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', diff --git a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t index b622ced624..913573432f 100644 --- a/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t +++ b/t/db_dependent/Acquisition/GetOrdersByBiblionumber.t @@ -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( { diff --git a/t/db_dependent/Acquisition/Invoices.t b/t/db_dependent/Acquisition/Invoices.t index b472ce7d16..399e9b7156 100644 --- a/t/db_dependent/Acquisition/Invoices.t +++ b/t/db_dependent/Acquisition/Invoices.t @@ -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}); diff --git a/t/db_dependent/Acquisition/NewOrder.t b/t/db_dependent/Acquisition/NewOrder.t index 79a53ec397..df455c2e67 100644 --- a/t/db_dependent/Acquisition/NewOrder.t +++ b/t/db_dependent/Acquisition/NewOrder.t @@ -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' }); diff --git a/t/db_dependent/Acquisition/OrderFromSubscription.t b/t/db_dependent/Acquisition/OrderFromSubscription.t index cc691d0585..626fb57d95 100644 --- a/t/db_dependent/Acquisition/OrderFromSubscription.t +++ b/t/db_dependent/Acquisition/OrderFromSubscription.t @@ -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}; diff --git a/t/db_dependent/Acquisition/TransferOrder.t b/t/db_dependent/Acquisition/TransferOrder.t index 7a5dcf71f9..6514582c2b 100644 --- a/t/db_dependent/Acquisition/TransferOrder.t +++ b/t/db_dependent/Acquisition/TransferOrder.t @@ -17,9 +17,6 @@ use MARC::Record; my $schema = Koha::Database->new()->schema(); $schema->storage->txn_begin(); -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; - my $bookseller1 = Koha::Acquisition::Bookseller->new( { name => "my vendor 1", diff --git a/t/db_dependent/Acquisition/close_reopen_basket.t b/t/db_dependent/Acquisition/close_reopen_basket.t index adc1d9ce91..1cb20d591a 100644 --- a/t/db_dependent/Acquisition/close_reopen_basket.t +++ b/t/db_dependent/Acquisition/close_reopen_basket.t @@ -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; diff --git a/t/db_dependent/Acquisition/populate_order_with_prices.t b/t/db_dependent/Acquisition/populate_order_with_prices.t index 874ffebec6..7e59ec29dc 100644 --- a/t/db_dependent/Acquisition/populate_order_with_prices.t +++ b/t/db_dependent/Acquisition/populate_order_with_prices.t @@ -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( diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t index 44a99b7e62..fb4459067c 100755 --- a/t/db_dependent/ArticleRequests.t +++ b/t/db_dependent/ArticleRequests.t @@ -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"); diff --git a/t/db_dependent/AudioAlerts.t b/t/db_dependent/AudioAlerts.t index f7cc825fd1..4f43b3c59a 100755 --- a/t/db_dependent/AudioAlerts.t +++ b/t/db_dependent/AudioAlerts.t @@ -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 diff --git a/t/db_dependent/Auth_with_cas.t b/t/db_dependent/Auth_with_cas.t index bb001ec030..5b87605545 100755 --- a/t/db_dependent/Auth_with_cas.t +++ b/t/db_dependent/Auth_with_cas.t @@ -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'); diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index ace46b86ed..f3e752cc1b 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -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 diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 08822d765c..e13a75ca34 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -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|); diff --git a/t/db_dependent/Circulation/GetTopIssues.t b/t/db_dependent/Circulation/GetTopIssues.t index 71a8cb319d..b2a33b048a 100644 --- a/t/db_dependent/Circulation/GetTopIssues.t +++ b/t/db_dependent/Circulation/GetTopIssues.t @@ -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 }; diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t index f29df5f94c..52512a0a21 100644 --- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t +++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t @@ -20,7 +20,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}; diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t index 42d8d1f670..0b20c8bd41 100755 --- a/t/db_dependent/CourseReserves.t +++ b/t/db_dependent/CourseReserves.t @@ -34,8 +34,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( diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t index 3337cfcf1c..c0528d6283 100755 --- a/t/db_dependent/DecreaseLoanHighHolds.t +++ b/t/db_dependent/DecreaseLoanHighHolds.t @@ -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(); diff --git a/t/db_dependent/Filter_MARC_ViewPolicy.t b/t/db_dependent/Filter_MARC_ViewPolicy.t index a873a5379a..552245a01b 100644 --- a/t/db_dependent/Filter_MARC_ViewPolicy.t +++ b/t/db_dependent/Filter_MARC_ViewPolicy.t @@ -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 { diff --git a/t/db_dependent/Holds/RevertWaitingStatus.t b/t/db_dependent/Holds/RevertWaitingStatus.t index 41a22e9e0a..90d9dba7c2 100755 --- a/t/db_dependent/Holds/RevertWaitingStatus.t +++ b/t/db_dependent/Holds/RevertWaitingStatus.t @@ -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"); diff --git a/t/db_dependent/Installer.t b/t/db_dependent/Installer.t index 636af43618..7ba654d62f 100644 --- a/t/db_dependent/Installer.t +++ b/t/db_dependent/Installer.t @@ -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(); diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 7d71b4e655..bf56a563a4 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -73,8 +73,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; ModItem({}, $biblio->biblionumber, $itemnumber); # Modify item; setting barcode. diff --git a/t/db_dependent/Koha/Acquisition/Currencies.t b/t/db_dependent/Koha/Acquisition/Currencies.t index 7e77593be9..0412160c42 100644 --- a/t/db_dependent/Koha/Acquisition/Currencies.t +++ b/t/db_dependent/Koha/Acquisition/Currencies.t @@ -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; diff --git a/t/db_dependent/Koha_Misc_Files.t b/t/db_dependent/Koha_Misc_Files.t index 689fb5296b..814a306426 100755 --- a/t/db_dependent/Koha_Misc_Files.t +++ b/t/db_dependent/Koha_Misc_Files.t @@ -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"); diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index bdeed6ead6..2389bf33d1 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -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|); diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t index 80415d62ca..5e2d056668 100644 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -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|); diff --git a/t/db_dependent/Members/Attributes.t b/t/db_dependent/Members/Attributes.t index b30291d470..2fe79df1bd 100644 --- a/t/db_dependent/Members/Attributes.t +++ b/t/db_dependent/Members/Attributes.t @@ -34,7 +34,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 issues|); $dbh->do(q|DELETE FROM borrowers|); diff --git a/t/db_dependent/Passwordrecovery.t b/t/db_dependent/Passwordrecovery.t index 37f5ca9658..aec58d9dd4 100755 --- a/t/db_dependent/Passwordrecovery.t +++ b/t/db_dependent/Passwordrecovery.t @@ -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 # diff --git a/t/db_dependent/Patron/Relationships.t b/t/db_dependent/Patron/Relationships.t index 5bc5b2308b..8e4fc8d8ec 100755 --- a/t/db_dependent/Patron/Relationships.t +++ b/t/db_dependent/Patron/Relationships.t @@ -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 diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t index 0d8d01d15c..a082a6cb09 100644 --- a/t/db_dependent/Reports/Guided.t +++ b/t/db_dependent/Reports/Guided.t @@ -260,6 +260,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"); diff --git a/t/db_dependent/Serials/Frequency.t b/t/db_dependent/Serials/Frequency.t index ac58981f7d..b185854947 100644 --- a/t/db_dependent/Serials/Frequency.t +++ b/t/db_dependent/Serials/Frequency.t @@ -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; diff --git a/t/db_dependent/Serials/GetNextSeq.t b/t/db_dependent/Serials/GetNextSeq.t index 53fbbe1a88..d369b6ccdf 100644 --- a/t/db_dependent/Serials/GetNextSeq.t +++ b/t/db_dependent/Serials/GetNextSeq.t @@ -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; diff --git a/t/db_dependent/Serials/Numberpattern.t b/t/db_dependent/Serials/Numberpattern.t index f703cd4254..84a62ccb5a 100644 --- a/t/db_dependent/Serials/Numberpattern.t +++ b/t/db_dependent/Serials/Numberpattern.t @@ -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; diff --git a/t/db_dependent/Serials_2.t b/t/db_dependent/Serials_2.t index 95c36f7d8e..ba91219b72 100644 --- a/t/db_dependent/Serials_2.t +++ b/t/db_dependent/Serials_2.t @@ -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( diff --git a/t/db_dependent/ShelfBrowser.t b/t/db_dependent/ShelfBrowser.t index f4dd9b9d78..27ff13f5e8 100644 --- a/t/db_dependent/ShelfBrowser.t +++ b/t/db_dependent/ShelfBrowser.t @@ -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|); diff --git a/t/db_dependent/cronjobs/advance_notices_digest.t b/t/db_dependent/cronjobs/advance_notices_digest.t index a666e1c785..7a61fe27ba 100644 --- a/t/db_dependent/cronjobs/advance_notices_digest.t +++ b/t/db_dependent/cronjobs/advance_notices_digest.t @@ -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'); -- 2.11.0