bug 5327 updated test file
[koha.git] / t / lib / KohaTest / Branch / GetBranches.pm
1 package KohaTest::Branch::GetBranches;
2 use base qw( KohaTest::Branch );
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 use C4::Branch;
10
11 =head2 STARTUP METHODS
12
13 These get run once, before the main test methods in this module
14
15 =cut
16
17 =head2 TEST METHODS
18
19 standard test methods
20
21 =head3 onlymine
22
23     When you pass in something true to GetBranches, it limits the
24     response to only your branch.
25
26 =cut
27
28 sub onlymine : Test( 4 ) {
29     my $self = shift;
30
31     # C4::Branch::GetBranches uses this variable, so make sure it exists.
32     ok( C4::Context->userenv->{'branch'}, 'we have a branch' );
33     my $branches = C4::Branch::GetBranches( 'onlymine' );
34     # diag( Data::Dumper->Dump( [ $branches ], [ 'branches' ] ) );
35     is( scalar( keys %$branches ), 1, 'one key for our branch only' );
36     ok( exists $branches->{ C4::Context->userenv->{'branch'} }, 'my branch was returned' );
37     is( $branches->{ C4::Context->userenv->{'branch'} }->{'branchcode'}, C4::Context->userenv->{'branch'}, 'branchcode' );
38     
39 }
40
41 1;