From ce96080f3005be5a63c9f2cab8d4b6c81e9b5b27 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Jul 2018 15:24:10 -0300 Subject: [PATCH] Bug 21133: Fix use statements order Basically the idea is: 1. Undefined subroutine &C4::Items::ModZebra called at /home/vagrant/kohaclone/C4/Items.pm line 302. => Then use C4::Items before C4::Biblio 2. Undefined subroutine &C4::Circulation::GetItem called at /home/vagrant/kohaclone/C4/Circulation.pm line 1290 => Then use C4::Circulation before C4::Items And sometimes these 2 rules do not work... Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Circulation/Branch.t | 2 +- t/db_dependent/Circulation/Chargelostitem.t | 2 +- t/db_dependent/Circulation/CheckIfIssuedToPatron.t | 9 +++------ .../Circulation/GetPendingOnSiteCheckouts.t | 2 +- t/db_dependent/Circulation/IsItemIssued.t | 2 +- .../Circulation/IssuingRules/maxsuspensiondays.t | 2 +- t/db_dependent/Circulation/Returns.t | 4 ++-- t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 4 ++-- t/db_dependent/Circulation/TooMany.t | 4 ++-- t/db_dependent/Circulation/issue.t | 4 ++-- t/db_dependent/Circulation/transfers.t | 4 ++-- t/db_dependent/CourseReserves.t | 4 ++-- t/db_dependent/Holds.t | 9 +++++---- t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t | 2 +- t/db_dependent/Holds/LocalHoldsPriority.t | 3 ++- t/db_dependent/Holds/RevertWaitingStatus.t | 12 +++++------- t/db_dependent/Items.t | 9 +++------ .../Items/AutomaticItemModificationByAge.t | 2 +- t/db_dependent/Items/DelItem.t | 7 ++----- t/db_dependent/Koha/Biblios.t | 2 +- t/db_dependent/Koha/Object.t | 3 ++- t/db_dependent/Koha/Patrons.t | 4 +--- t/db_dependent/Labels/t_Batch.t | 2 +- t/db_dependent/Members/GetAllIssues.t | 2 +- t/db_dependent/Members/IssueSlip.t | 2 +- t/db_dependent/Patron/Borrower_Discharge.t | 4 ++-- t/db_dependent/Reserves.t | 2 +- t/db_dependent/RotatingCollections.t | 4 ++-- t/db_dependent/ShelfBrowser.t | 2 +- t/db_dependent/api/v1/holds.t | 2 +- 30 files changed, 53 insertions(+), 63 deletions(-) diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t index c56e68711a..10bc52e280 100644 --- a/t/db_dependent/Circulation/Branch.t +++ b/t/db_dependent/Circulation/Branch.t @@ -17,9 +17,9 @@ use Modern::Perl; -use C4::Biblio; use C4::Circulation; use C4::Items; +use C4::Biblio; use C4::Context; use Koha::Patrons; diff --git a/t/db_dependent/Circulation/Chargelostitem.t b/t/db_dependent/Circulation/Chargelostitem.t index 658400c924..7dc0fe3e02 100644 --- a/t/db_dependent/Circulation/Chargelostitem.t +++ b/t/db_dependent/Circulation/Chargelostitem.t @@ -7,9 +7,9 @@ use Test::MockModule; use t::lib::Mocks; use t::lib::TestBuilder; +use C4::Circulation; use C4::Biblio; use C4::Items; -use C4::Circulation; use Koha::Patrons; use MARC::Record; diff --git a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t b/t/db_dependent/Circulation/CheckIfIssuedToPatron.t index c25f7dc8ee..b06d0c3ff7 100644 --- a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t +++ b/t/db_dependent/Circulation/CheckIfIssuedToPatron.t @@ -17,20 +17,17 @@ use Modern::Perl; -use Test::More tests => 22; +use Test::More tests => 21; use Test::MockModule; use t::lib::TestBuilder; -use C4::Biblio; +use C4::Circulation; use C4::Items; +use C4::Biblio; use Koha::Library; use Koha::Patrons; use MARC::Record; -BEGIN { - use_ok('C4::Circulation'); -} - my $schema = Koha::Database->schema; $schema->storage->txn_begin; diff --git a/t/db_dependent/Circulation/GetPendingOnSiteCheckouts.t b/t/db_dependent/Circulation/GetPendingOnSiteCheckouts.t index d47f38ac7c..236626cb70 100644 --- a/t/db_dependent/Circulation/GetPendingOnSiteCheckouts.t +++ b/t/db_dependent/Circulation/GetPendingOnSiteCheckouts.t @@ -21,8 +21,8 @@ use Test::More tests => 2; use Test::MockModule; use t::lib::TestBuilder; -use C4::Biblio; use C4::Circulation; +use C4::Biblio; use C4::Items; use C4::Members; diff --git a/t/db_dependent/Circulation/IsItemIssued.t b/t/db_dependent/Circulation/IsItemIssued.t index b175c55375..ab26f0c3cb 100644 --- a/t/db_dependent/Circulation/IsItemIssued.t +++ b/t/db_dependent/Circulation/IsItemIssued.t @@ -20,9 +20,9 @@ use Modern::Perl; use Test::More tests => 5; use Test::MockModule; -use C4::Biblio; use C4::Circulation; use C4::Items; +use C4::Biblio; use Koha::Database; use Koha::DateUtils; use Koha::Patrons; diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t index f02efcda84..86f64fdd27 100644 --- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t +++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t @@ -5,9 +5,9 @@ use MARC::Record; use MARC::Field; use C4::Context; -use C4::Biblio qw( AddBiblio ); use C4::Circulation qw( AddIssue AddReturn ); use C4::Items qw( AddItem ); +use C4::Biblio qw( AddBiblio ); use Koha::Database; use Koha::DateUtils; use Koha::Patron::Debarments qw( GetDebarments DelDebarment ); diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t index a8e4ddadbe..50f733bb52 100644 --- a/t/db_dependent/Circulation/Returns.t +++ b/t/db_dependent/Circulation/Returns.t @@ -24,10 +24,10 @@ use Test::Warn; use t::lib::Mocks; use t::lib::TestBuilder; -use C4::Biblio; +use C4::Members; use C4::Circulation; use C4::Items; -use C4::Members; +use C4::Biblio; use Koha::Database; use Koha::Account::Lines; use Koha::DateUtils; diff --git a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t index f76b17360a..506423d676 100644 --- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t +++ b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t @@ -18,10 +18,10 @@ use Modern::Perl; use Test::More tests => 10; use C4::Context; -use C4::Biblio; -use C4::Members; use C4::Circulation; +use C4::Biblio; use C4::Items; +use C4::Members; use C4::Context; use Koha::DateUtils qw( dt_from_string ); diff --git a/t/db_dependent/Circulation/TooMany.t b/t/db_dependent/Circulation/TooMany.t index 193752ff26..a7f19db8f1 100644 --- a/t/db_dependent/Circulation/TooMany.t +++ b/t/db_dependent/Circulation/TooMany.t @@ -18,10 +18,10 @@ use Modern::Perl; use Test::More tests => 7; use C4::Context; -use C4::Biblio; use C4::Members; -use C4::Circulation; use C4::Items; +use C4::Biblio; +use C4::Circulation; use C4::Context; use Koha::DateUtils qw( dt_from_string ); diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index 6f190f070f..f613f081f1 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -23,10 +23,10 @@ use DateTime::Duration; use t::lib::Mocks; use t::lib::TestBuilder; -use C4::Biblio; use C4::Circulation; -use C4::Context; use C4::Items; +use C4::Biblio; +use C4::Context; use C4::Reserves; use Koha::Checkouts; use Koha::Database; diff --git a/t/db_dependent/Circulation/transfers.t b/t/db_dependent/Circulation/transfers.t index 299c059fff..a377c932cb 100644 --- a/t/db_dependent/Circulation/transfers.t +++ b/t/db_dependent/Circulation/transfers.t @@ -16,10 +16,10 @@ # along with Koha; if not, see . use Modern::Perl; -use C4::Biblio; use C4::Context; -use C4::Items; use C4::Circulation; +use C4::Biblio; +use C4::Items; use Koha::Database; use Koha::DateUtils; use DateTime::Duration; diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t index 8c47e59c90..2dabc67638 100755 --- a/t/db_dependent/CourseReserves.t +++ b/t/db_dependent/CourseReserves.t @@ -23,10 +23,10 @@ use Koha::Database; use t::lib::TestBuilder; BEGIN { + use_ok('C4::Items', qw(AddItem)); use_ok('C4::Biblio'); - use_ok('C4::Context'); use_ok('C4::CourseReserves', qw/:all/); - use_ok('C4::Items', qw(AddItem)); + use_ok('C4::Context'); use_ok('MARC::Field'); use_ok('MARC::Record'); } diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 93fe7459ba..3c5fd1e90a 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,21 +7,22 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 55; +use Test::More tests => 54; use MARC::Record; -use C4::Biblio; +use Koha::Patrons; use C4::Items; +use C4::Biblio; +use C4::Reserves; use C4::Calendar; + use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Biblios; use Koha::Holds; -use Koha::Patrons; BEGIN { use FindBin; use lib $FindBin::Bin; - use_ok('C4::Reserves'); } my $schema = Koha::Database->new->schema; diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t index 1a9edd882e..a5237d9aa3 100755 --- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t +++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t @@ -3,8 +3,8 @@ use Modern::Perl; use C4::Context; -use C4::Items; use C4::Circulation; +use C4::Items; use Koha::IssuingRule; use Test::More tests => 6; diff --git a/t/db_dependent/Holds/LocalHoldsPriority.t b/t/db_dependent/Holds/LocalHoldsPriority.t index f107e71d09..af914d6895 100755 --- a/t/db_dependent/Holds/LocalHoldsPriority.t +++ b/t/db_dependent/Holds/LocalHoldsPriority.t @@ -7,10 +7,11 @@ use C4::Context; use Test::More tests => 6; use MARC::Record; + +use Koha::Patrons; use C4::Biblio; use C4::Items; use Koha::Database; -use Koha::Patrons; use t::lib::TestBuilder; diff --git a/t/db_dependent/Holds/RevertWaitingStatus.t b/t/db_dependent/Holds/RevertWaitingStatus.t index 4df597f176..9877e68b2c 100755 --- a/t/db_dependent/Holds/RevertWaitingStatus.t +++ b/t/db_dependent/Holds/RevertWaitingStatus.t @@ -16,20 +16,18 @@ # along with Koha; if not, see . use Modern::Perl; - -use t::lib::Mocks; -use C4::Context; - use Test::More tests => 3; use MARC::Record; -use C4::Biblio; -use C4::Items; -use C4::Reserves; use Koha::Libraries; use Koha::Patrons; +use C4::Context; +use C4::Items; +use C4::Biblio; +use C4::Reserves; use t::lib::TestBuilder; +use t::lib::Mocks; my $schema = Koha::Database->schema; $schema->storage->txn_begin; diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index ef098734c9..92151d662d 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -20,7 +20,9 @@ use Modern::Perl; use Data::Dumper; use MARC::Record; +use C4::Items; use C4::Biblio; +use Koha::Items; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Library; @@ -31,15 +33,10 @@ use Koha::Caches; use t::lib::Mocks; use t::lib::TestBuilder; -use Test::More tests => 14; +use Test::More tests => 12; use Test::Warn; -BEGIN { - use_ok('C4::Items'); - use_ok('Koha::Items'); -} - my $schema = Koha::Database->new->schema; my $location = 'My Location'; diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t index b93c62681c..17172be5d2 100644 --- a/t/db_dependent/Items/AutomaticItemModificationByAge.t +++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t @@ -7,9 +7,9 @@ use MARC::Field; use DateTime; use DateTime::Duration; +use C4::Items; use C4::Biblio; use C4::Context; -use C4::Items; use Koha::DateUtils; use t::lib::TestBuilder; diff --git a/t/db_dependent/Items/DelItem.t b/t/db_dependent/Items/DelItem.t index 2880f11b03..03f1f5840e 100644 --- a/t/db_dependent/Items/DelItem.t +++ b/t/db_dependent/Items/DelItem.t @@ -1,15 +1,12 @@ use Modern::Perl; use MARC::Record; +use C4::Items; use C4::Biblio; use t::lib::TestBuilder; -use Test::More tests => 7; - -BEGIN { - use_ok('C4::Items'); -} +use Test::More tests => 6; my $schema = Koha::Database->schema; $schema->storage->txn_begin; diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t index 17ab937e51..e92ae415b1 100644 --- a/t/db_dependent/Koha/Biblios.t +++ b/t/db_dependent/Koha/Biblios.t @@ -22,8 +22,8 @@ use Modern::Perl; use Test::More tests => 5; use Test::Exception; -use C4::Biblio; use C4::Items; +use C4::Biblio; use C4::Reserves; use Koha::DateUtils qw( dt_from_string output_pref ); diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index abb0d740ad..746a0e8084 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -23,8 +23,9 @@ use Test::Warn; use DateTime; use C4::Context; -use C4::Biblio; # AddBiblio use C4::Circulation; # AddIssue +use C4::Biblio; # AddBiblio + use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Libraries; diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 6a966223b5..8df1dea320 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -26,10 +26,8 @@ use Time::Fake; use DateTime; use JSON; -use C4::Biblio; -use C4::Circulation; - use C4::Circulation; +use C4::Biblio; use Koha::Holds; use Koha::Patrons; diff --git a/t/db_dependent/Labels/t_Batch.t b/t/db_dependent/Labels/t_Batch.t index ed8c8e84b1..49929464df 100644 --- a/t/db_dependent/Labels/t_Batch.t +++ b/t/db_dependent/Labels/t_Batch.t @@ -27,8 +27,8 @@ use MARC::Field; use t::lib::TestBuilder; use C4::Context; -use C4::Biblio; use C4::Items; +use C4::Biblio; use Koha::Libraries; BEGIN { diff --git a/t/db_dependent/Members/GetAllIssues.t b/t/db_dependent/Members/GetAllIssues.t index 21701cb05c..bffd0cbcdc 100644 --- a/t/db_dependent/Members/GetAllIssues.t +++ b/t/db_dependent/Members/GetAllIssues.t @@ -22,10 +22,10 @@ use Test::MockModule; use t::lib::TestBuilder; +use C4::Circulation; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Circulation; use Koha::Libraries; use Koha::Patrons; use MARC::Record; diff --git a/t/db_dependent/Members/IssueSlip.t b/t/db_dependent/Members/IssueSlip.t index cbf3a72cc0..0dee8d90bb 100644 --- a/t/db_dependent/Members/IssueSlip.t +++ b/t/db_dependent/Members/IssueSlip.t @@ -24,10 +24,10 @@ use Test::MockModule; use Test::MockTime qw( set_fixed_time ); use t::lib::TestBuilder; +use C4::Circulation; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Circulation; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Library; diff --git a/t/db_dependent/Patron/Borrower_Discharge.t b/t/db_dependent/Patron/Borrower_Discharge.t index d43b49e464..ffd3370f81 100644 --- a/t/db_dependent/Patron/Borrower_Discharge.t +++ b/t/db_dependent/Patron/Borrower_Discharge.t @@ -19,10 +19,10 @@ use Test::More tests => 19; use Test::Warn; use MARC::Record; -use C4::Biblio qw( AddBiblio ); use C4::Circulation qw( AddIssue AddReturn ); -use C4::Context; use C4::Items qw( AddItem ); +use C4::Biblio qw( AddBiblio ); +use C4::Context; use Koha::Patrons; use Koha::Patron::Discharge; diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 0b12de6de9..a458e8daa8 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -27,9 +27,9 @@ use t::lib::TestBuilder; use MARC::Record; use DateTime::Duration; -use C4::Biblio; use C4::Circulation; use C4::Items; +use C4::Biblio; use C4::Members; use C4::Reserves; use Koha::Caches; diff --git a/t/db_dependent/RotatingCollections.t b/t/db_dependent/RotatingCollections.t index 9c46b33619..e00410c729 100644 --- a/t/db_dependent/RotatingCollections.t +++ b/t/db_dependent/RotatingCollections.t @@ -17,13 +17,13 @@ use Modern::Perl; -use Test::More tests => 52; +use Test::More tests => 51; use C4::Context; +use C4::RotatingCollections; use C4::Biblio; use Koha::Library; BEGIN { - use_ok('C4::RotatingCollections'); } can_ok( diff --git a/t/db_dependent/ShelfBrowser.t b/t/db_dependent/ShelfBrowser.t index de01139fba..f4dd9b9d78 100644 --- a/t/db_dependent/ShelfBrowser.t +++ b/t/db_dependent/ShelfBrowser.t @@ -6,9 +6,9 @@ use List::Util qw( shuffle ); use MARC::Field; use MARC::Record; -use C4::Biblio; use C4::Context; use C4::Items; +use C4::Biblio; use Koha::Database; use t::lib::TestBuilder; diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index b3e3678c0c..1e00be1a3b 100644 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -25,6 +25,7 @@ use t::lib::Mocks; use DateTime; use C4::Context; +use Koha::Patrons; use C4::Reserves; use C4::Items; @@ -33,7 +34,6 @@ use Koha::DateUtils; use Koha::Biblios; use Koha::Biblioitems; use Koha::Items; -use Koha::Patrons; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new(); -- 2.39.5