From 7d2f0786c42a75b0c37e36529dd14c82e627ea72 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Jan 2016 11:22:19 +0000 Subject: [PATCH] Bug 15629: Koha::Libraries - Remove GetBranchesInCategory (3) C4::Branch::GetBranchesInCategory is not used anymore and can be removed. Test plan: git grep GetBranchesInCategory should not return any result. --- C4/Branch.pm | 22 ---------------------- t/db_dependent/Branch.t | 35 +---------------------------------- 2 files changed, 1 insertion(+), 56 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index ae2216a..057a043 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -36,7 +36,6 @@ BEGIN { &GetBranchDetail &ModBranch &GetBranchInfo - &GetBranchesInCategory &mybranch ); @EXPORT_OK = qw( &onlymine &mybranch ); @@ -310,27 +309,6 @@ sub GetBranchDetail { return $sth->fetchrow_hashref(); } -=head2 GetBranchesInCategory - - my $branches = GetBranchesInCategory($categorycode); - -Returns a href: keys %$branches eq (branchcode,branchname) . - -=cut - -sub GetBranchesInCategory { - my ($categorycode) = @_; - my @branches; - my $dbh = C4::Context->dbh(); - my $sth=$dbh->prepare( "SELECT b.branchcode FROM branchrelations r, branches b - where r.branchcode=b.branchcode and r.categorycode=?"); - $sth->execute($categorycode); - while (my $branch = $sth->fetchrow) { - push @branches, $branch; - } - return( \@branches ); -} - =head2 GetBranchInfo $results = GetBranchInfo($branchcode); diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index 7c7ed75..72a59d4 100644 --- a/t/db_dependent/Branch.t +++ b/t/db_dependent/Branch.t @@ -21,7 +21,7 @@ use Modern::Perl; use C4::Context; use Data::Dumper; -use Test::More tests => 23; +use Test::More tests => 21; use C4::Branch; use Koha::Libraries; @@ -41,7 +41,6 @@ can_ok( GetBranchDetail ModBranch GetBranchInfo - GetBranchesInCategory mybranch ) ); @@ -249,38 +248,6 @@ $b2->{issuing} = undef; $b2->{categories} = \@cat; is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1 and CAT2' ); -#Test GetBranchesInCategory -my $brCat1 = GetBranchesInCategory( $cat1->{categorycode} ); -my @b = ( $b2->{branchcode} ); -is_deeply( $brCat1, \@b, 'CAT1 has branch BRB' ); - -my $b3 = { - add => 1, - branchcode => 'BRC', - branchname => 'BranchC', - branchaddress1 => 'adr1C', - branchaddress2 => 'adr2C', - branchaddress3 => 'adr3C', - branchzip => 'zipC', - branchcity => 'cityC', - branchstate => 'stateC', - branchcountry => 'countryC', - branchphone => 'phoneC', - branchfax => 'faxC', - branchemail => 'emailC', - branchurl => 'urlC', - branchip => 'ipC', - branchprinter => undef, - branchnotes => 'noteC', - opac_info => 'opacC', - CAT1 => 1, - CAT2 => 1 -}; -ModBranch($b3); -$brCat1 = GetBranchesInCategory( $cat1->{categorycode} ); -push( @b, $b3->{branchcode} ); -is_deeply( $brCat1, \@b, 'CAT1 has branch BRB and BRC' ); - #TODO later: test mybranchine and onlymine # Actually we cannot mock C4::Context->userenv in unit tests -- 2.1.0