Bug 15168: (followup) remove useless diags
[koha.git] / t / db_dependent / sysprefs.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Copyright (C) 2012 BibLibre SARL
6 # Copyright (C) 2013 Equinox Software, Inc.
7 #
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 use Modern::Perl;
22 use Test::More tests => 5;
23 use C4::Context;
24
25 # Start transaction
26 my $dbh = C4::Context->dbh;
27 $dbh->{RaiseError} = 1;
28 $dbh->{AutoCommit} = 0;
29
30 my $opacheader    = C4::Context->preference('opacheader');
31 my $newopacheader = "newopacheader";
32
33 C4::Context->set_preference( 'OPACHEADER', $newopacheader );
34 is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' );
35
36 C4::Context->set_preference( 'opacheader', $opacheader );
37 is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive');
38
39 $ENV{OVERRIDE_SYSPREF_opacheader} = 'this is an override';
40 C4::Context->clear_syspref_cache();
41 is(
42     C4::Context->preference('opacheader'),
43     'this is an override',
44     'system preference value overridden from environment'
45 );
46
47 is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef');
48
49 C4::Context->set_preference( 'IDoNotExist', 'NonExistent' );
50 is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' );