Bug 15629: Koha::Libraries - Remove GetBranchDetail
[koha.git] / t / db_dependent / Branch.t
index 791f545..73e7ec7 100644 (file)
@@ -21,7 +21,7 @@ use Modern::Perl;
 use C4::Context;
 use Data::Dumper;
 
-use Test::More tests => 23;
+use Test::More tests => 19;
 
 use C4::Branch;
 use Koha::Libraries;
@@ -38,12 +38,8 @@ can_ok(
       GetBranch
       GetBranches
       GetBranchesLoop
-      GetBranchDetail
-      get_branchinfos_of
       ModBranch
       GetBranchInfo
-      GetBranchesInCategory
-      ModBranchCategoryInfo
       mybranch
       )
 );
@@ -83,7 +79,8 @@ my $b1 = {
     branchip       => 'ipA',
     branchprinter  => undef,
     branchnotes    => 'noteA',
-    opac_info      => 'opacA'
+    opac_info      => 'opacA',
+    issuing        => undef,
 };
 my $b2 = {
     branchcode     => 'BRB',
@@ -105,6 +102,7 @@ my $b2 = {
     branchprinter  => undef,
     branchnotes    => 'noteB',
     opac_info      => 'opacB',
+    issuing        => undef,
 };
 ModBranch($b1);
 is( ModBranch($b2), undef, 'the field add is missing' );
@@ -120,12 +118,6 @@ is( Koha::Libraries->search->count,             $count + 1, "branch BRB deleted"
 is( GetBranchName( $b1->{branchcode} ),
     $b1->{branchname}, "GetBranchName returns the right name" );
 
-#Test GetBranchDetail
-my $branchdetail = GetBranchDetail( $b1->{branchcode} );
-$branchdetail->{add} = 1;
-$b1->{issuing}       = undef;    # Not used in DB
-is_deeply( $branchdetail, $b1, 'branchdetail is right' );
-
 #Test Getbranches
 my $branches = GetBranches();
 is( scalar( keys %$branches ),
@@ -152,21 +144,18 @@ $b1 = {
     branchip       => 'ipA modified',
     branchprinter  => undef,
     branchnotes    => 'notesA modified',
-    opac_info      => 'opacA modified'
+    opac_info      => 'opacA modified',
+    issuing        => undef,
 };
 
 ModBranch($b1);
 is( Koha::Libraries->search->count, $count + 1,
     "A branch has been modified, no new branch added" );
-$branchdetail = GetBranchDetail( $b1->{branchcode} );
-$b1->{issuing} = undef;
-is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA");
 
 #Test categories
 my $count_cat  = Koha::LibraryCategories->search->count;
 
 my $cat1 = {
-    add              => 1,
     categorycode     => 'CAT1',
     categoryname     => 'catname1',
     codedescription  => 'catdesc1',
@@ -174,7 +163,6 @@ my $cat1 = {
     show_in_pulldown => 1
 };
 my $cat2 = {
-    add              => 1,
     categorycode     => 'CAT2',
     categoryname     => 'catname2',
     categorytype     => 'catype2',
@@ -190,19 +178,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 +207,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',
@@ -248,6 +229,7 @@ $b2 = {
     branchprinter  => undef,
     branchnotes    => 'noteB',
     opac_info      => 'opacB',
+    issuing        => undef,
     CAT1           => 1,
     CAT2           => 1
 };
@@ -256,42 +238,9 @@ $b2info = GetBranchInfo( $b2->{branchcode} );
 push( @cat, $cat2->{categorycode} );
 delete $b2->{CAT1};
 delete $b2->{CAT2};
-$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