Bug 17709 - Article request broken - 'internal server error'
[koha.git] / t / db_dependent / sysprefs.t
blob340e89a730727666d64714986df32cadc41fd00c
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright (C) 2012 BibLibre SARL
6 # Copyright (C) 2013 Equinox Software, Inc.
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.
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.
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>.
21 use Modern::Perl;
22 use Test::More tests => 8;
23 use C4::Context;
25 # Start transaction
26 my $dbh = C4::Context->dbh;
27 $dbh->{RaiseError} = 1;
28 $dbh->{AutoCommit} = 0;
30 my $opacheader = C4::Context->preference('opacheader');
31 my $newopacheader = "newopacheader";
33 C4::Context->set_preference( 'OPACHEADER', $newopacheader );
34 is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' );
36 C4::Context->set_preference( 'opacheader', $opacheader );
37 is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive');
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'
47 is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef');
49 C4::Context->set_preference( 'IDoNotExist', 'NonExistent' );
50 is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' );
52 C4::Context->set_preference('testpreference', 'abc');
53 C4::Context->delete_preference('testpreference');
54 is(C4::Context->preference('testpreference'), undef, 'deleting preferences');
56 C4::Context->set_preference('testpreference', 'def');
57 # Delete from the database, it should still be in cache
58 $dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'");
59 is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
60 C4::Context->clear_syspref_cache();
61 is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
63 $dbh->rollback;