Bug 42385: Remove _GetCircControlBranch
Removes the deprecated _GetCircControlBranch function and its export
from C4::Circulation. Removes the corresponding tests from
Circulation.t (now covered by t/db_dependent/Koha/Policy/Circulation.t).
Test plan:
1. Apply patch
2. Run:
$ ktd --shell
k$ prove t/db_dependent/Circulation.t \
t/db_dependent/Koha/Policy/Circulation.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Signed-off-by: Alex Carver [Acerock7] <alex@rcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 8e784622815a2db2ce6f558987d7c0b0951ceec0)
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
# Conflicts:
# C4/Circulation.pm
# t/db_dependent/Circulation.t
This commit is contained in:
parent
4f1b98160e
commit
275d870be7
|
|
@ -72,7 +72,6 @@ BEGIN {
|
||||||
ProcessOfflinePayment
|
ProcessOfflinePayment
|
||||||
ProcessOfflineIssue
|
ProcessOfflineIssue
|
||||||
);
|
);
|
||||||
push @EXPORT_OK, '_GetCircControlBranch'; # This is wrong!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
@ -861,7 +860,8 @@ sub CanBookBeIssued {
|
||||||
my $dbh = C4::Context->dbh;
|
my $dbh = C4::Context->dbh;
|
||||||
my $patron_unblessed = $patron->unblessed;
|
my $patron_unblessed = $patron->unblessed;
|
||||||
|
|
||||||
my $circ_library = Koha::Libraries->find( Koha::Policy::Circulation->circ_control_library( $item_object, $patron ) );
|
my $circ_library =
|
||||||
|
Koha::Libraries->find( Koha::Policy::Circulation->circ_control_library( $item_object, $patron ) );
|
||||||
|
|
||||||
my $now = dt_from_string();
|
my $now = dt_from_string();
|
||||||
|
|
||||||
|
|
@ -3306,44 +3306,6 @@ sub _FixOverduesOnReturn {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 _GetCircControlBranch
|
|
||||||
|
|
||||||
my $circ_control_branch = _GetCircControlBranch($item, $patron);
|
|
||||||
|
|
||||||
Internal function :
|
|
||||||
|
|
||||||
Return the library code to be used to determine which circulation
|
|
||||||
policy applies to a transaction. Looks up the CircControl and
|
|
||||||
HomeOrHoldingBranch system preferences.
|
|
||||||
|
|
||||||
C<$item> is an item object.
|
|
||||||
|
|
||||||
C<$patron> is a patron object.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub _GetCircControlBranch {
|
|
||||||
my ( $item, $patron ) = @_;
|
|
||||||
my $circcontrol = C4::Context->preference('CircControl');
|
|
||||||
my $branch;
|
|
||||||
|
|
||||||
if ( $circcontrol eq 'PickupLibrary' and ( C4::Context->userenv and C4::Context->userenv->{'branch'} ) ) {
|
|
||||||
$branch = C4::Context->userenv->{'branch'};
|
|
||||||
} elsif ( $circcontrol eq 'PatronLibrary' ) {
|
|
||||||
$branch = $patron->branchcode;
|
|
||||||
} else {
|
|
||||||
my $branchfield = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch';
|
|
||||||
$branch = $item->get_column($branchfield);
|
|
||||||
|
|
||||||
# default to item home branch if holdingbranch is used
|
|
||||||
# and is not defined
|
|
||||||
if ( !defined($branch) && $branchfield eq 'holdingbranch' ) {
|
|
||||||
$branch = $item->homebranch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $branch;
|
|
||||||
}
|
|
||||||
|
|
||||||
=head2 GetUpcomingDueIssues
|
=head2 GetUpcomingDueIssues
|
||||||
|
|
||||||
my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } );
|
my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } );
|
||||||
|
|
@ -3709,7 +3671,8 @@ sub AddRenewal {
|
||||||
my $patron = Koha::Patrons->find($borrowernumber) or return; # FIXME Should do more than just return
|
my $patron = Koha::Patrons->find($borrowernumber) or return; # FIXME Should do more than just return
|
||||||
my $patron_unblessed = $patron->unblessed;
|
my $patron_unblessed = $patron->unblessed;
|
||||||
|
|
||||||
my $circ_library = Koha::Libraries->find( Koha::Policy::Circulation->circ_control_library( $item_object, $patron ) );
|
my $circ_library =
|
||||||
|
Koha::Libraries->find( Koha::Policy::Circulation->circ_control_library( $item_object, $patron ) );
|
||||||
|
|
||||||
my $schema = Koha::Database->schema;
|
my $schema = Koha::Database->schema;
|
||||||
$schema->txn_do(
|
$schema->txn_do(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ use CGI qw( -utf8 );
|
||||||
use C4::Auth qw( get_template_and_user );
|
use C4::Auth qw( get_template_and_user );
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use C4::Output qw( output_html_with_http_headers );
|
use C4::Output qw( output_html_with_http_headers );
|
||||||
use C4::Circulation;
|
|
||||||
use Koha::Policy::Circulation;
|
use Koha::Policy::Circulation;
|
||||||
use C4::Letters;
|
use C4::Letters;
|
||||||
use Koha::Checkouts;
|
use Koha::Checkouts;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use Modern::Perl;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
use Test::NoWarnings;
|
use Test::NoWarnings;
|
||||||
use Test::More tests => 91;
|
use Test::More tests => 78;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
use Test::MockModule;
|
use Test::MockModule;
|
||||||
use Test::Deep qw( cmp_deeply );
|
use Test::Deep qw( cmp_deeply );
|
||||||
|
|
@ -195,89 +195,6 @@ my $borrower = $builder->build_object(
|
||||||
|
|
||||||
t::lib::Mocks::mock_preference( 'AutoReturnCheckedOutItems', 0 );
|
t::lib::Mocks::mock_preference( 'AutoReturnCheckedOutItems', 0 );
|
||||||
|
|
||||||
# No userenv, PickupLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'IndependentBranches', '0' );
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'PickupLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'PickupLibrary',
|
|
||||||
'CircControl changed to PickupLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
$item->get_column($HomeOrHoldingBranch),
|
|
||||||
'_GetCircControlBranch returned item branch (no userenv defined)'
|
|
||||||
);
|
|
||||||
|
|
||||||
# No userenv, PatronLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'PatronLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'PatronLibrary',
|
|
||||||
'CircControl changed to PatronLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
$borrower->branchcode,
|
|
||||||
'_GetCircControlBranch returned borrower branch'
|
|
||||||
);
|
|
||||||
|
|
||||||
# No userenv, ItemHomeLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'ItemHomeLibrary',
|
|
||||||
'CircControl changed to ItemHomeLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
$item->get_column($HomeOrHoldingBranch),
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
'_GetCircControlBranch returned item branch'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Now, set a userenv
|
|
||||||
t::lib::Mocks::mock_userenv( { branchcode => $library2->{branchcode} } );
|
|
||||||
is( C4::Context->userenv->{branch}, $library2->{branchcode}, 'userenv set' );
|
|
||||||
|
|
||||||
# Userenv set, PickupLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'PickupLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'PickupLibrary',
|
|
||||||
'CircControl changed to PickupLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
$library2->{branchcode},
|
|
||||||
'_GetCircControlBranch returned current branch'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Userenv set, PatronLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'PatronLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'PatronLibrary',
|
|
||||||
'CircControl changed to PatronLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
$borrower->branchcode,
|
|
||||||
'_GetCircControlBranch returned borrower branch'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Userenv set, ItemHomeLibrary
|
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' );
|
|
||||||
is(
|
|
||||||
C4::Context->preference('CircControl'),
|
|
||||||
'ItemHomeLibrary',
|
|
||||||
'CircControl changed to ItemHomeLibrary'
|
|
||||||
);
|
|
||||||
is(
|
|
||||||
C4::Circulation::_GetCircControlBranch( $item, $borrower ),
|
|
||||||
$item->get_column($HomeOrHoldingBranch),
|
|
||||||
'_GetCircControlBranch returned item branch'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Reset initial configuration
|
# Reset initial configuration
|
||||||
t::lib::Mocks::mock_preference( 'CircControl', $CircControl );
|
t::lib::Mocks::mock_preference( 'CircControl', $CircControl );
|
||||||
is(
|
is(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue