View | Details | Raw Unified | Return to bug 15295
Collapse All | Expand All

(-)a/C4/Branch.pm (-25 lines)
Lines 28-34 BEGIN { Link Here
28
    $VERSION = 3.07.00.049;
28
    $VERSION = 3.07.00.049;
29
	@ISA    = qw(Exporter);
29
	@ISA    = qw(Exporter);
30
	@EXPORT = qw(
30
	@EXPORT = qw(
31
		&GetBranchCategory
32
		&GetBranchName
31
		&GetBranchName
33
		&GetBranch
32
		&GetBranch
34
		&GetBranches
33
		&GetBranches
Lines 284-313 sub ModBranch { Link Here
284
    }
283
    }
285
}
284
}
286
285
287
=head2 GetBranchCategory
288
289
$results = GetBranchCategory($categorycode);
290
291
C<$results> is an hashref
292
293
=cut
294
295
sub GetBranchCategory {
296
    my ($catcode) = @_;
297
    return unless $catcode;
298
299
    my $dbh = C4::Context->dbh;
300
    my $sth;
301
302
    $sth = $dbh->prepare(q{
303
        SELECT *
304
        FROM branchcategories
305
        WHERE categorycode = ?
306
    });
307
    $sth->execute( $catcode );
308
    return $sth->fetchrow_hashref;
309
}
310
311
=head2 GetBranchCategories
286
=head2 GetBranchCategories
312
287
313
  my $categories = GetBranchCategories($categorytype,$show_in_pulldown,$selected_in_pulldown);
288
  my $categories = GetBranchCategories($categorytype,$show_in_pulldown,$selected_in_pulldown);
(-)a/t/db_dependent/Branch.t (-16 / +1 lines)
Lines 21-27 use Modern::Perl; Link Here
21
use C4::Context;
21
use C4::Context;
22
use Data::Dumper;
22
use Data::Dumper;
23
23
24
use Test::More tests => 30;
24
use Test::More tests => 26;
25
25
26
use C4::Branch;
26
use C4::Branch;
27
use Koha::Libraries;
27
use Koha::Libraries;
Lines 34-40 BEGIN { Link Here
34
}
34
}
35
can_ok(
35
can_ok(
36
    'C4::Branch', qw(
36
    'C4::Branch', qw(
37
      GetBranchCategory
38
      GetBranchName
37
      GetBranchName
39
      GetBranch
38
      GetBranch
40
      GetBranches
39
      GetBranches
Lines 209-233 delete $cat2->{add}; Link Here
209
delete $new_category{add};
208
delete $new_category{add};
210
is_deeply($categories, [ $cat1,$cat2,\%new_category ], 'retrieve all expected library categories (bug 10515)');
209
is_deeply($categories, [ $cat1,$cat2,\%new_category ], 'retrieve all expected library categories (bug 10515)');
211
210
212
#test GetBranchCategory
213
my $cat1detail = GetBranchCategory( $cat1->{categorycode} );
214
delete $cat1->{add};
215
is_deeply( $cat1detail, $cat1, 'CAT1 details are right' );
216
my $category = GetBranchCategory('LIBCATCODE');
217
is_deeply($category, \%new_category, 'fetched newly added library category');
218
219
my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete;
211
my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete;
220
is( $del, 1, 'One row affected' );
212
is( $del, 1, 'One row affected' );
221
213
222
$categories = GetBranchCategories();
214
$categories = GetBranchCategories();
223
is( scalar( @$categories ), $count_cat + 2, "Category  CAT2 deleted" );
215
is( scalar( @$categories ), $count_cat + 2, "Category  CAT2 deleted" );
224
216
225
my $cat2detail = GetBranchCategory( $cat2->{categorycode} );
226
is( $cat2detail, undef, 'CAT2 doesnt exist' );
227
228
$category = GetBranchCategory();
229
is($category, undef, 'retrieve library category only if code is supplied (bug 10515)');
230
231
$b2->{CAT1} = 1;
217
$b2->{CAT1} = 1;
232
ModBranch($b2);
218
ModBranch($b2);
233
is( GetBranchesCount(), $count + 2, 'BRB added' );
219
is( GetBranchesCount(), $count + 2, 'BRB added' );
234
- 

Return to bug 15295