Koha/t/db_dependent/sysprefs.t
Owen Leonard 12074faff9
Bug 22880: (follow-up) Loose ends: Better DB update, global inclusion, etc.
This patch makes a number of improvements and ties up some loose ends
where the old system preference usage wasn't getting replaced.

 - Removes news-specific code for defining the language of news
   items queried for the OPAC home page. An identical language variable
   is already defined globally.

   Previous to this patch an 'opacheader' news item would only appear on
   the OPAC home page. Now it should appear on all OPAC pages.

 - Changes the database update so that 'opacheader' news
   items will be inserted with a default title, matching the interface's
   requirement that the title field be populated.

 - The database update will also now insert the old opacheader system
   preference contents into the news item for all active languages as
   defined in the 'opaclanguages' system preference. This helps match
   the previous behavior in which the opacheader contents were the same
   for all languages.

 - Adds support for the new opacheader news item to the self checkout,
   self check-in, and OPAC maintenance pages.

 - Updates sysprefs.t which was using the opacheader preference to test
   on. I've changed it to use URLLinkText instead.

 - Removes the addition of the opacheader system preference from the
   installation SQL file.

Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-02-24 13:24:25 +00:00

61 lines
2.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright (C) 2012 BibLibre SARL
# Copyright (C) 2013 Equinox Software, Inc.
#
# 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 <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 8;
use C4::Context;
use Koha::Database;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
my $URLLinkText = C4::Context->preference('URLLinkText');
my $newURLLinkText = "newURLLinkText";
C4::Context->set_preference( 'URLLINKTEXT', $newURLLinkText );
is( C4::Context->preference('URLLinkText'), $newURLLinkText, 'The pref should have been set correctly' );
C4::Context->set_preference( 'URLLinkText', $URLLinkText );
is( C4::Context->preference('URLLINKTEXT'), $URLLinkText, 'A pref name should be case insensitive');
$ENV{OVERRIDE_SYSPREF_URLLinkText} = 'this is an override';
C4::Context->clear_syspref_cache();
is(
C4::Context->preference('URLLinkText'),
'this is an override',
'system preference value overridden from environment'
);
is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef');
C4::Context->set_preference( 'IDoNotExist', 'NonExistent' );
is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' );
C4::Context->set_preference('testpreference', 'abc');
C4::Context->delete_preference('testpreference');
is(C4::Context->preference('testpreference'), undef, 'deleting preferences');
C4::Context->set_preference('testpreference', 'def');
# Delete from the database, it should still be in cache
$dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'");
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
C4::Context->clear_syspref_cache();
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');