Bug 20568: (QA follow-up) Get rid of the id column
[koha.git] / t / Koha_Template_Plugin_KohaPlugins.t
blob723f07c4ade9a7767f9437dbc4fc95a719325b1c
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use Test::More tests => 10;
6 use CGI;
7 use File::Basename;
8 use File::Spec;
9 use File::Temp qw( tempdir tempfile );
10 use FindBin qw($Bin);
11 use Archive::Extract;
12 use Module::Load::Conditional qw(can_load);
13 use Test::MockModule;
15 use C4::Context;
16 use t::lib::Mocks;
18 BEGIN {
19 push( @INC, dirname(__FILE__) );
21 use_ok('Koha::Plugins');
22 use_ok('Koha::Plugins::Handler');
23 use_ok('Koha::Plugins::Base');
24 use_ok('Koha::Plugin::Test');
27 my $mock_plugin = Test::MockModule->new( 'Koha::Plugin::Test' );
28 $mock_plugin->mock( 'test_template', sub {
29 my ( $self, $file ) = @_;
30 my $template = $self->get_template({ file => $file });
31 $template->param( filename => $file );
32 return $template->output;
33 });
35 use_ok( 'Koha::Template::Plugin::KohaPlugins', 'Can use Koha::Template::Plugin::KohaPlugins' );
37 ok( my $plugin = Koha::Template::Plugin::KohaPlugins->new(), 'Able to instantiate template plugin' );
39 t::lib::Mocks::mock_preference('UseKohaPlugins',1);
40 t::lib::Mocks::mock_config('enable_plugins',1);
41 ok( index( $plugin->get_plugins_opac_js, 'Koha::Plugin::Test::opac_js' ) != -1, 'Test plugin opac_js return value is part of code returned by get_plugins_opac_js' );
42 ok( index( $plugin->get_plugins_opac_head, 'Koha::Plugin::Test::opac_head' ) != -1, 'Test plugin opac_head return value is part of code returned by get_plugins_opac_head' );
44 t::lib::Mocks::mock_preference('UseKohaPlugins',0);
45 t::lib::Mocks::mock_config('enable_plugins',0);
46 is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empty' );
47 is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' );