Bug 10515: add regression tests
[koha.git] / t / db_dependent / Branch.t
blobcc19f21a102b1e98d42ce51d9e9e2204594be14c
1 #!/usr/bin/perl
3 # Copyright 2013 Equinox Software, Inc.
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Modern::Perl;
21 use C4::Context;
22 use Data::Dumper;
24 use Test::More tests => 6;
26 use C4::Branch;
28 BEGIN {
29 use FindBin;
30 use lib $FindBin::Bin;
31 use_ok('C4::Branch');
34 # Start transaction
35 my $dbh = C4::Context->dbh;
36 $dbh->{AutoCommit} = 0;
37 $dbh->{RaiseError} = 1;
39 # clear the slate
40 $dbh->do('DELETE FROM branchcategories');
42 my @category_types = GetCategoryTypes();
43 is_deeply(\@category_types, [ 'searchdomain', 'properties' ], 'received expected library category types');
45 my %new_category = (
46 categorycode => 'LIBCATCODE',
47 categoryname => 'library category name',
48 codedescription => 'library category code description',
49 categorytype => 'searchdomain',
50 show_in_pulldown => 1,
52 ModBranchCategoryInfo({
53 add => 1,
54 %new_category,
55 });
57 my $category = GetBranchCategory('LIBCATCODE');
58 is_deeply($category, \%new_category, 'fetched newly added library category');
60 $category = GetBranchCategory();
61 is($category, undef, 'retrieve library category only if code is supplied (bug 10515)');
63 my $categories = GetBranchCategories();
64 is_deeply($categories, [ \%new_category ], 'retrieve all expected library categories (bug 10515)');
66 $categories = GetBranchCategories(undef, undef, 'LIBCATCODE');
67 is_deeply($categories, [ { %new_category, selected => 1 } ], 'retrieve expected, eselected library category (bug 10515)');
69 $dbh->rollback();