From 5ed2680cf522f1308a6ba0b419380211265e514d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 3 Dec 2015 15:02:35 +0000 Subject: [PATCH] Bug 15295! Koha::Libraries - Remove ModBranchCategoryInfo This has been replaced with Koha::Library->update_categories and Koha::Library->add_to_categories --- C4/Branch.pm | 22 ---------------------- t/db_dependent/Branch.t | 20 +++++--------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index c4e4cc1..7e8b187 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -38,7 +38,6 @@ BEGIN { &ModBranch &GetBranchInfo &GetBranchesInCategory - &ModBranchCategoryInfo &mybranch ); @EXPORT_OK = qw( &onlymine &mybranch ); @@ -381,27 +380,6 @@ sub GetBranchInfo { return \@results; } -=head2 ModBranchCategoryInfo - -&ModBranchCategoryInfo($data); -sets the data from the editbranch form, and writes to the database... - -=cut - -sub ModBranchCategoryInfo { - my ($data) = @_; - my $dbh = C4::Context->dbh; - if ($data->{'add'}){ - # we are doing an insert - my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)"); - $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} ); - } - else { - # modifying - my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?"); - $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) ); - } -} 1; __END__ diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index 791f545..9076a2d 100644 --- a/t/db_dependent/Branch.t +++ b/t/db_dependent/Branch.t @@ -43,7 +43,6 @@ can_ok( ModBranch GetBranchInfo GetBranchesInCategory - ModBranchCategoryInfo mybranch ) ); @@ -166,7 +165,6 @@ is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA"); my $count_cat = Koha::LibraryCategories->search->count; my $cat1 = { - add => 1, categorycode => 'CAT1', categoryname => 'catname1', codedescription => 'catdesc1', @@ -174,7 +172,6 @@ my $cat1 = { show_in_pulldown => 1 }; my $cat2 = { - add => 1, categorycode => 'CAT2', categoryname => 'catname2', categorytype => 'catype2', @@ -190,19 +187,12 @@ my %new_category = ( show_in_pulldown => 1, ); -ModBranchCategoryInfo({ - add => 1, - %new_category, -}); - -ModBranchCategoryInfo($cat1); -ModBranchCategoryInfo($cat2); +Koha::LibraryCategory->new(\%new_category)->store; +Koha::LibraryCategory->new($cat1)->store; +Koha::LibraryCategory->new($cat2)->store; my $categories = Koha::LibraryCategories->search; is( $categories->count, $count_cat + 3, "Two categories added" ); -delete $cat1->{add}; -delete $cat2->{add}; -delete $new_category{add}; my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete; is( $del, 1, 'One row affected' ); @@ -226,8 +216,8 @@ $b2->{issuing} = undef; $b2->{categories} = \@cat; is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' ); -ModBranchCategoryInfo({add => 1,%$cat2}); -is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two catgories added" ); +Koha::LibraryCategory->new($cat2)->store; +is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" ); $b2 = { branchcode => 'BRB', branchname => 'BranchB', -- 1.7.10.4