&GetBranchDetail
&ModBranch
&GetBranchInfo
- &GetBranchesInCategory
&mybranch
);
@EXPORT_OK = qw( &onlymine &mybranch );
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);
use C4::Context;
use Data::Dumper;
-use Test::More tests => 23;
+use Test::More tests => 21;
use C4::Branch;
use Koha::Libraries;
GetBranchDetail
ModBranch
GetBranchInfo
- GetBranchesInCategory
mybranch
)
);
$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