3 # This file is part of Koha.
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>.
20 use Test
::More tests
=> 4;
26 # Test the plugin is usable
27 use_ok
( 'Koha::Template::Plugin::Koha' );
28 ok
( my $cache = Koha
::Template
::Plugin
::Koha
->new() );
30 subtest
"Koha::Template::Plugin::Koha::Version tests" => sub {
34 # Variables for mocking Koha::version()
40 # Mock Koha::version()
41 my $koha = new Test
::MockModule
('Koha');
42 $koha->mock( 'version', sub {
43 return "$major.$minor.$maintenance.$development";
46 my $rnd = new String
::Random
;
47 # development version test
48 $major = $rnd->randregex('\d');
49 $minor = $rnd->randregex('\d\d');
50 $maintenance = $rnd->randregex('\d\d');
51 $development = $rnd->randregex('\d\d\d');
52 my $version = "$major.$minor.$maintenance.$development";
53 my $res = Koha
::Template
::Plugin
::Koha
::Version
( $version );
57 release
=> $major . "." . $minor,
58 maintenance
=> $major . "." . $minor . "." . $maintenance,
59 development
=> $development
60 }, "Correct development version");
63 # maintenance release test
64 $major = $rnd->randregex('\d');
65 $minor = $rnd->randregex('\d\d');
66 $maintenance = $rnd->randregex('\d\d');
68 $version = "$major.$minor.$maintenance.$development";
69 $res = Koha
::Template
::Plugin
::Koha
::Version
( $version );
73 release
=> $major . "." . $minor,
74 maintenance
=> $major . "." . $minor . "." . $maintenance,
76 }, "Correct maintenance version");
80 subtest
"Koha::Template::Plugin::Koha::ArePluginsEnabled tests" => sub {
84 t
::lib
::Mocks
::mock_config
( 'enable_plugins', 1 );
85 is
(Koha
::Template
::Plugin
::Koha
::ArePluginsEnabled
(), 1, "Correct ArePluginsEnabled is yes");
87 t
::lib
::Mocks
::mock_config
( 'enable_plugins', 0 );
88 is
(Koha
::Template
::Plugin
::Koha
::ArePluginsEnabled
(), 0, "Correct ArePluginsEnabled is no");