Bug 24612: Make hold-transfer-slip take reserve_id
[koha.git] / t / Koha_Template_Plugin_Koha.t
blob5cba73b22c6c2cea03b62678c246e77e5e5ccf5e
1 #!/usr/bin/perl
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>.
18 use Modern::Perl;
20 use Test::More tests => 4;
21 use Test::MockModule;
22 use t::lib::Mocks;
24 use String::Random;
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 {
32 plan tests => 2;
34 # Variables for mocking Koha::version()
35 my $major;
36 my $minor;
37 my $maintenance;
38 my $development;
40 # Mock Koha::version()
41 my $koha = new Test::MockModule('Koha');
42 $koha->mock( 'version', sub {
43 return "$major.$minor.$maintenance.$development";
44 });
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 );
54 is_deeply( $res, {
55 major => $major,
56 minor => $minor,
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');
67 $development = "000";
68 $version = "$major.$minor.$maintenance.$development";
69 $res = Koha::Template::Plugin::Koha::Version( $version );
70 is_deeply( $res, {
71 major => $major,
72 minor => $minor,
73 release => $major . "." . $minor,
74 maintenance => $major . "." . $minor . "." . $maintenance,
75 development => undef
76 }, "Correct maintenance version");
80 subtest "Koha::Template::Plugin::Koha::ArePluginsEnabled tests" => sub {
82 plan tests => 2;
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");