5 use Test
::More tests
=> 10;
9 use File
::Temp
qw( tempdir tempfile );
12 use Module::Load::Conditional qw(can_load);
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;
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' );