From 5ff045a83e6f9429aea6f1c4cebc5c2fe773d93c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 2 Mar 2020 17:01:42 +0000 Subject: [PATCH] Bug 24759: Rename renewalbranch to renewal_branchcode Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 2 +- Koha/Item.pm | 16 ++++++++-------- t/db_dependent/Koha/Item.t | 28 ++++++++++++++-------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 64582ce3f1..4865f7874b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3051,7 +3051,7 @@ sub AddRenewal { # Add the renewal to stats UpdateStats( { - branch => $item_object->renewalbranch({branch => $branch}), + branch => $item_object->renewal_branchcode({branch => $branch}), type => 'renew', amount => $charge, itemnumber => $itemnumber, diff --git a/Koha/Item.pm b/Koha/Item.pm index 148f3d6ab6..567a294911 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -701,30 +701,30 @@ sub as_marc_field { return $field; } -=head3 renewalbranch +=head3 renewal_branchcode -Returns the branch to be recorded in statistics renewal of the item +Returns the branchcode to be recorded in statistics renewal of the item =cut -sub renewalbranch { +sub renewal_branchcode { my ($self, $params ) = @_; my $interface = C4::Context->interface; my $branchcode; if ( $interface eq 'opac' ){ - my $renewalbranch = C4::Context->preference('OpacRenewalBranch'); - if( !defined $renewalbranch || $renewalbranch eq 'opacrenew' ){ + my $renewal_branchcode = C4::Context->preference('OpacRenewalBranch'); + if( !defined $renewal_branchcode || $renewal_branchcode eq 'opacrenew' ){ $branchcode = 'OPACRenew'; } - elsif ( $renewalbranch eq 'itemhomebranch' ) { + elsif ( $renewal_branchcode eq 'itemhomebranch' ) { $branchcode = $self->homebranch; } - elsif ( $renewalbranch eq 'patronhomebranch' ) { + elsif ( $renewal_branchcode eq 'patronhomebranch' ) { $branchcode = $self->checkout->patron->branchcode; } - elsif ( $renewalbranch eq 'checkoutbranch' ) { + elsif ( $renewal_branchcode eq 'checkoutbranch' ) { $branchcode = $self->checkout->branchcode; } else { diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 116d9458e2..b807b881ce 100644 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -438,7 +438,7 @@ subtest 'deletion' => sub { $schema->storage->txn_rollback; }; -subtest 'renewalbranch' => sub { +subtest 'renewal_branchcode' => sub { plan tests => 15; $schema->storage->txn_begin; @@ -456,31 +456,31 @@ subtest 'renewalbranch' => sub { C4::Context->interface( 'intranet' ); t::lib::Mocks::mock_userenv({ branchcode => $branch->branchcode }); - is( $item->renewalbranch, $branch->branchcode, "If interface not opac, we get the branch from context"); - is( $item->renewalbranch({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in"); + is( $item->renewal_branchcode, $branch->branchcode, "If interface not opac, we get the branch from context"); + is( $item->renewal_branchcode({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in"); C4::Context->set_userenv(51, 'userid4tests', undef, 'firstname', 'surname', undef, undef, 0, undef, undef, undef ); #mock userenv doesn't let us set null branch - is( $item->renewalbranch({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set"); + is( $item->renewal_branchcode({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set"); C4::Context->interface( 'opac' ); t::lib::Mocks::mock_preference('OpacRenewalBranch', undef); - is( $item->renewalbranch, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew"); - is( $item->renewalbranch({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed"); + is( $item->renewal_branchcode, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew"); + is( $item->renewal_branchcode({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch', 'none'); - is( $item->renewalbranch, '', "If interface opac and OpacRenewalBranch is none, we get blank string"); - is( $item->renewalbranch({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed"); + is( $item->renewal_branchcode, '', "If interface opac and OpacRenewalBranch is none, we get blank string"); + is( $item->renewal_branchcode({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is none, we get blank string even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch', 'checkoutbranch'); - is( $item->renewalbranch, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout"); - is( $item->renewalbranch({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed"); + is( $item->renewal_branchcode, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout"); + is( $item->renewal_branchcode({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch','patronhomebranch'); - is( $item->renewalbranch, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron"); - is( $item->renewalbranch({branch=>'TURKEY'}), $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron even if branch passed"); + is( $item->renewal_branchcode, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron"); + is( $item->renewal_branchcode({branch=>'TURKEY'}), $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron even if branch passed"); t::lib::Mocks::mock_preference('OpacRenewalBranch','itemhomebranch'); - is( $item->renewalbranch, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item"); - is( $item->renewalbranch({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed"); + is( $item->renewal_branchcode, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item"); + is( $item->renewal_branchcode({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed"); }; -- 2.39.5