From 988c52ed68ac9395291a136642688332c3044505 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/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/Items.t | 2 -- t/db_dependent/Koha/Acquisition/Currencies.t | 4 ---- t/db_dependent/Koha/BiblioUtils.t | 3 --- 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/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 - 34 files changed, 1 insertion(+), 56 deletions(-) diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 78322ef79f..857cc9ea64 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -123,9 +123,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 a900885de6..93e195d572 100644 --- a/t/db_dependent/Acquisition/CancelReceipt.t +++ b/t/db_dependent/Acquisition/CancelReceipt.t @@ -35,8 +35,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 b932828186..98ff3b8df5 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 b17dcec7dc..dfa481b0d6 100644 --- a/t/db_dependent/Acquisition/NewOrder.t +++ b/t/db_dependent/Acquisition/NewOrder.t @@ -14,8 +14,6 @@ use Koha::Acquisition::Orders; my $schema = Koha::Database->new()->schema(); $schema->storage->txn_begin(); -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; C4::Context->_new_userenv('xxx'); C4::Context->set_userenv(42, 'ordercreator', '0042', 'Order', 'Creator', 'CPL', 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/ArticleRequests.t b/t/db_dependent/ArticleRequests.t index 884c2e2598..a526e8223f 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 issuingrules"); 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 48b2cef53e..0a77c95cbc 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 02b45c366a..2afcf7c56c 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -46,9 +46,6 @@ $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; my $dbh = C4::Context->dbh; -# 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 b35f35aba2..5615700fe0 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 86f64fdd27..f11cdeba4a 100644 --- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t +++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.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; 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 a85048f4b9..3fcc1ec2bd 100755 --- a/t/db_dependent/DecreaseLoanHighHolds.t +++ b/t/db_dependent/DecreaseLoanHighHolds.t @@ -34,8 +34,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(); $dbh->do('DELETE FROM issues'); diff --git a/t/db_dependent/Filter_MARC_ViewPolicy.t b/t/db_dependent/Filter_MARC_ViewPolicy.t index 64759fa5bb..1c7b2cb0ab 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 9877e68b2c..e07c0f9137 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/Items.t b/t/db_dependent/Items.t index bc7aaa9feb..672ecba97f 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -72,8 +72,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({}, $bibnum, $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/BiblioUtils.t b/t/db_dependent/Koha/BiblioUtils.t index 85bf9217b9..54f8c4bb15 100755 --- a/t/db_dependent/Koha/BiblioUtils.t +++ b/t/db_dependent/Koha/BiblioUtils.t @@ -33,9 +33,6 @@ use_ok('Koha::Biblios'); my $schema = Koha::Database->new()->schema(); $schema->storage->txn_begin(); -my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; - my @branches = Koha::Libraries->search(); my $borrower = Koha::Patrons->search()->next(); 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 d6f8c79682..854c1e647b 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 2714317458..1ffb3a5382 100644 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -53,7 +53,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 cd409ed012..171b01f025 100644 --- a/t/db_dependent/Members/Attributes.t +++ b/t/db_dependent/Members/Attributes.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(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/Reports/Guided.t b/t/db_dependent/Reports/Guided.t index 827cfc17a6..7ce8cd9127 100644 --- a/t/db_dependent/Reports/Guided.t +++ b/t/db_dependent/Reports/Guided.t @@ -256,6 +256,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} = 0; 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 4b277d00ed..155f71488c 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|); -- 2.11.0