1 # This file is part of Koha.
3 # Copyright 2018 Koha Development Team
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Test::More tests => 4;
22 use t::lib::TestBuilder;
23 use Koha::Config::SysPrefs;
25 my $schema = Koha::Database->new->schema;
26 $schema->storage->txn_begin;
28 my $builder = t::lib::TestBuilder->new;
30 my $nb_of_prefs = Koha::Config::SysPrefs->search->count;
31 my $new_pref = Koha::Config::SysPref->new({
32 variable => 'ShouldNotBeDone',
33 value => 'but a good test?',
35 explanation => 'just for CRUD sake',
39 is( Koha::Config::SysPrefs->search->count, $nb_of_prefs + 1, 'The 1 pref should have been added' );
40 my $retrieved_pref = Koha::Config::SysPrefs->find('ShouldNotBeDone');
41 is( $retrieved_pref->value, $new_pref->value, 'Find a pref by variable should return the correct pref' );
43 $retrieved_pref->delete;
44 is( Koha::Config::SysPrefs->search->count, $nb_of_prefs, 'Delete should have deleted the pref' );
46 subtest 'get_yaml_pref_hash' => sub {
50 my $the_pref = Koha::Config::SysPrefs->find({variable=>'ItemsDeniedRenewal'});
54 multi_this: [that,another]
59 this => ['just_that'],
60 multi_this => ['that','another'],
62 my $got_hash = $the_pref->get_yaml_pref_hash();
63 is_deeply($got_hash,$expected_hash,"Pref fetched and converted correctly");
67 $schema->storage->txn_rollback;