From 9e4a46b4a4f8bdd9b54a29e2b4f4054d111e900d 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=utf8 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 Signed-off-by: Martin Renvoize http://bugs.koha-community.org/show_bug.cgi?id=15294 Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- 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 c9c5505365..14fcd20842 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 bf95a037e3..c98ea1a5da 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(); -- 2.39.5