Bug 7413: Add "No renewal before" to the circulation and fine rules
[koha.git] / t / Templates.t
1 #!/usr/bin/perl
2
3 # Copyright 2013 Equinox Software, Inc.
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
18
19 use Modern::Perl;
20 use Test::More tests => 3;
21 use Test::MockModule;
22 use CGI;
23
24 BEGIN {
25     use_ok('C4::Templates');
26 }
27
28 my @languages = (); # stores the list of active languages
29                     # for the syspref mock
30
31 my $module_context = new Test::MockModule('C4::Context');
32
33 $module_context->mock(
34     preference => sub {
35         my ($self, $pref) = @_;
36         if ($pref =~ /language/) {
37             return join ',', @languages;
38         } else {
39             return 'XXX';
40         }
41   },
42 );
43
44 delete $ENV{TTTP_ACCEPT_LANGUAGE};
45
46 my $query = CGI->new();
47 @languages = ('de-DE', 'fr-FR');
48 is(C4::Templates::getlanguage($query, 'opac'), 'de-DE', 'default to first language specified in syspref (bug 10560)');
49
50 @languages = ();
51 is(C4::Templates::getlanguage($query, 'opac'), 'en', 'default to English if no language specified in syspref (bug 10560)');