Bug 19036: Add ability to enable credit number for only some credit types
[koha.git] / t / db_dependent / sysprefs.t
blobf43f8e3d665851c776f5de40a1b0436f82c0f694
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;
24 use Koha::Database;
26 my $schema = Koha::Database->new->schema;
27 $schema->storage->txn_begin;
28 my $dbh = C4::Context->dbh;
30 my $URLLinkText = C4::Context->preference('URLLinkText');
31 my $newURLLinkText = "newURLLinkText";
33 C4::Context->set_preference( 'URLLINKTEXT', $newURLLinkText );
34 is( C4::Context->preference('URLLinkText'), $newURLLinkText, 'The pref should have been set correctly' );
36 C4::Context->set_preference( 'URLLinkText', $URLLinkText );
37 is( C4::Context->preference('URLLINKTEXT'), $URLLinkText, 'A pref name should be case insensitive');
39 $ENV{OVERRIDE_SYSPREF_URLLinkText} = 'this is an override';
40 C4::Context->clear_syspref_cache();
41 is(
42 C4::Context->preference('URLLinkText'),
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');