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 => 3;
25 # Test the plugin is usable
26 use_ok( 'Koha::Template::Plugin::Koha' );
27 ok( my $cache = Koha::Template::Plugin::Koha->new() );
29 subtest "Koha::Template::Plugin::Koha::Version tests" => sub {
33 # Variables for mocking KOHAVERSION
39 # Mock C4::Context::KOHAVERSION
40 my $context = new Test::MockModule('C4::Context');
41 $context->mock( 'KOHAVERSION', sub {
42 return "$major.$minor.$maintenance.$development";
45 my $rnd = new String::Random;
46 # development version test
47 $major = $rnd->randregex('\d');
48 $minor = $rnd->randregex('\d\d');
49 $maintenance = $rnd->randregex('\d\d');
50 $development = $rnd->randregex('\d\d\d');
51 my $version = "$major.$minor.$maintenance.$development";
52 my $res = Koha::Template::Plugin::Koha::Version( $version );
55 release => $major . "." . $minor,
56 maintenance => $major . "." . $minor . "." . $maintenance,
57 development => $development
58 }, "Correct development version");
61 # maintenance release test
62 $major = $rnd->randregex('\d');
63 $minor = $rnd->randregex('\d\d');
64 $maintenance = $rnd->randregex('\d\d');
66 $version = "$major.$minor.$maintenance.$development";
67 $res = Koha::Template::Plugin::Koha::Version( $version );
70 release => $major . "." . $minor,
71 maintenance => $major . "." . $minor . "." . $maintenance,
73 }, "Correct maintenance version");