From 3150b6cd2814ec18c30510de7028e31e860b83f2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 3 Dec 2015 14:09:36 +0000 Subject: [PATCH] Bug 15295: Koha::Libraries - Remove CheckBranchCategorycode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This verification is now done in admin/branches.pl, no need for a special subroutine/method, it's 1 line only called once. Signed-off-by: Marc VĂ©ron --- C4/Branch.pm | 21 --------------------- t/db_dependent/Branch.t | 23 +---------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index c9c5505..14fcd20 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -36,7 +36,6 @@ BEGIN { &GetBranchDetail &get_branchinfos_of &ModBranch - &CheckBranchCategorycode &GetBranchInfo &GetCategoryTypes &GetBranchCategories @@ -490,26 +489,6 @@ sub ModBranchCategoryInfo { $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) ); } } - -=head2 CheckBranchCategorycode - -$number_rows_affected = CheckBranchCategorycode($categorycode); - -=cut - -sub CheckBranchCategorycode { - - # check to see if the branchcode is being used in the database somewhere.... - my ($categorycode) = @_; - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare( - "select count(*) from branchrelations where categorycode=?"); - $sth->execute($categorycode); - my ($total) = $sth->fetchrow_array; - return $total; -} - sub GetBranchesCount { my $dbh = C4::Context->dbh(); my $query = "SELECT COUNT(*) AS branches_count FROM branches"; diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index bf95a03..c98ea1a 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 => 34; +use Test::More tests => 30; use C4::Branch; use Koha::Libraries; @@ -42,7 +42,6 @@ can_ok( GetBranchDetail get_branchinfos_of ModBranch - CheckBranchCategorycode GetBranchInfo GetCategoryTypes GetBranchCategories @@ -229,19 +228,9 @@ is( $cat2detail, undef, 'CAT2 doesnt exist' ); $category = GetBranchCategory(); is($category, undef, 'retrieve library category only if code is supplied (bug 10515)'); -#Test CheckBranchCategoryCode -my $check1 = CheckBranchCategorycode( $cat1->{categorycode} ); -my $check2 = CheckBranchCategorycode( $cat2->{categorycode} ); -like( $check1, '/^\d+$/', "CheckBranchCategorycode returns a number" ); - $b2->{CAT1} = 1; ModBranch($b2); is( GetBranchesCount(), $count + 2, 'BRB added' ); -is( - CheckBranchCategorycode( $cat1->{categorycode} ), - $check1 + 1, - 'BRB added to CAT1' -); #Test GetBranchInfo my $b1info = GetBranchInfo( $b1->{branchcode} ); @@ -284,11 +273,6 @@ $b2 = { }; ModBranch($b2); $b2info = GetBranchInfo( $b2->{branchcode} ); -is( - CheckBranchCategorycode( $cat2->{categorycode} ), - $check2 + 1, - 'BRB added to CAT2' -); push( @cat, $cat2->{categorycode} ); delete $b2->{CAT1}; delete $b2->{CAT2}; @@ -327,11 +311,6 @@ ModBranch($b3); $brCat1 = GetBranchesInCategory( $cat1->{categorycode} ); push( @b, $b3->{branchcode} ); is_deeply( $brCat1, \@b, 'CAT1 has branch BRB and BRC' ); -is( - CheckBranchCategorycode( $cat1->{categorycode} ), - $check1 + 2, - 'BRC has been added to CAT1' -); #Test GetCategoryTypes my @category_types = GetCategoryTypes(); -- 1.7.10.4