From 5aeefa25ac94495afd9a1c7fa5aae3f05a1d1907 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 17 Jul 2013 17:27:36 +0000 Subject: [PATCH] Bug 10515: add regression tests Signed-off-by: Galen Charlton --- t/db_dependent/Branch.t | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 t/db_dependent/Branch.t diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t new file mode 100644 index 0000000000..cc19f21a10 --- /dev/null +++ b/t/db_dependent/Branch.t @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +# Copyright 2013 Equinox Software, Inc. +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, see . + +use Modern::Perl; + +use C4::Context; +use Data::Dumper; + +use Test::More tests => 6; + +use C4::Branch; + +BEGIN { + use FindBin; + use lib $FindBin::Bin; + use_ok('C4::Branch'); +} + +# Start transaction +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + +# clear the slate +$dbh->do('DELETE FROM branchcategories'); + +my @category_types = GetCategoryTypes(); +is_deeply(\@category_types, [ 'searchdomain', 'properties' ], 'received expected library category types'); + +my %new_category = ( + categorycode => 'LIBCATCODE', + categoryname => 'library category name', + codedescription => 'library category code description', + categorytype => 'searchdomain', + show_in_pulldown => 1, +); +ModBranchCategoryInfo({ + add => 1, + %new_category, +}); + +my $category = GetBranchCategory('LIBCATCODE'); +is_deeply($category, \%new_category, 'fetched newly added library category'); + +$category = GetBranchCategory(); +is($category, undef, 'retrieve library category only if code is supplied (bug 10515)'); + +my $categories = GetBranchCategories(); +is_deeply($categories, [ \%new_category ], 'retrieve all expected library categories (bug 10515)'); + +$categories = GetBranchCategories(undef, undef, 'LIBCATCODE'); +is_deeply($categories, [ { %new_category, selected => 1 } ], 'retrieve expected, eselected library category (bug 10515)'); + +$dbh->rollback(); -- 2.20.1