3 # This file is part of Koha.
5 # Copyright (c) 2015 Mark Tompsett
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Test::More tests => 8;
27 use_ok('C4::Context');
31 can_ok('C4::Koha','GetKohaAuthorisedValuesMapping');
39 my $dbh = C4::Context->dbh;
40 my $count = $dbh->selectrow_arrayref("SELECT COUNT(*) FROM marc_subfield_structure WHERE kohafield LIKE 'item%';");
41 skip "Lacking item mappings in marc_subfield_structure",5 unless ($count && $count->[0]>0);
42 $count = $dbh->selectrow_arrayref("SELECT COUNT(*) FROM authorised_values;");
43 skip "Lacking authorised_values",5 unless ($count && $count->[0]>0);
44 $avMappingOPAC = GetKohaAuthorisedValuesMapping( { interface => 'opac' });
45 $avMappingStaff = GetKohaAuthorisedValuesMapping( { interface => 'staff' });
46 $avMappingUndef1 = GetKohaAuthorisedValuesMapping( { interface => undef });
47 $avMappingUndef2 = GetKohaAuthorisedValuesMapping( { } );
48 $avMappingUndef3 = GetKohaAuthorisedValuesMapping();
49 is_deeply($avMappingUndef1,$avMappingStaff,"Undefined interface = Staff test 1");
50 is_deeply($avMappingUndef2,$avMappingStaff,"Undefined interface = Staff test 2");
51 is_deeply($avMappingUndef3,$avMappingStaff,"Undefined interface = Staff test 3");
52 isnt($avMappingOPAC ,undef,"OPAC has a mapping");
53 isnt($avMappingStaff,undef,"Staff has a mapping");