|
Lines 9-15
use File::Temp qw( tempdir tempfile );
Link Here
|
| 9 |
use FindBin qw($Bin); |
9 |
use FindBin qw($Bin); |
| 10 |
use Module::Load::Conditional qw(can_load); |
10 |
use Module::Load::Conditional qw(can_load); |
| 11 |
use Test::MockModule; |
11 |
use Test::MockModule; |
| 12 |
use Test::More tests => 42; |
12 |
use Test::More tests => 44; |
| 13 |
|
13 |
|
| 14 |
use C4::Context; |
14 |
use C4::Context; |
| 15 |
use Koha::Database; |
15 |
use Koha::Database; |
|
Lines 77-91
close $fh;
Link Here
|
| 77 |
my $classname = ref($plugin); |
77 |
my $classname = ref($plugin); |
| 78 |
like( $plugin->test_template($fn), qr/^I am $fn/, 'Template works' ); |
78 |
like( $plugin->test_template($fn), qr/^I am $fn/, 'Template works' ); |
| 79 |
|
79 |
|
|
|
80 |
$plugin->enable; |
| 81 |
|
| 80 |
# testing GetPlugins |
82 |
# testing GetPlugins |
| 81 |
my @plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ |
83 |
my @plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ |
| 82 |
method => 'report' |
84 |
method => 'report' |
| 83 |
}); |
85 |
}); |
|
|
86 |
|
| 84 |
my @names = map { $_->get_metadata()->{'name'} } @plugins; |
87 |
my @names = map { $_->get_metadata()->{'name'} } @plugins; |
| 85 |
is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" ); |
88 |
is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" ); |
| 86 |
@plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ |
89 |
@plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ |
| 87 |
metadata => { my_example_tag => 'find_me' }, |
90 |
metadata => { my_example_tag => 'find_me' }, |
| 88 |
}); |
91 |
}); |
|
|
92 |
|
| 89 |
@names = map { $_->get_metadata()->{'name'} } @plugins; |
93 |
@names = map { $_->get_metadata()->{'name'} } @plugins; |
| 90 |
is( scalar grep( /^Test Plugin$/, @names), 1, "GetPlugins also found Test Plugin via a metadata tag" ); |
94 |
is( scalar grep( /^Test Plugin$/, @names), 1, "GetPlugins also found Test Plugin via a metadata tag" ); |
| 91 |
# Test two metadata conditions; one does not exist for Test.pm |
95 |
# Test two metadata conditions; one does not exist for Test.pm |
|
Lines 95-100
my @plugins2 = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({
Link Here
|
| 95 |
}); |
99 |
}); |
| 96 |
isnt( scalar @plugins2, scalar @plugins, 'GetPlugins with two metadata conditions' ); |
100 |
isnt( scalar @plugins2, scalar @plugins, 'GetPlugins with two metadata conditions' ); |
| 97 |
|
101 |
|
|
|
102 |
$plugin->disable; |
| 103 |
|
| 104 |
@plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins(); |
| 105 |
@names = map { $_->get_metadata()->{'name'} } @plugins; |
| 106 |
is( scalar grep( /^Test Plugin$/, @names), 0, "GetPlugins does not found disabled Test Plugin" ); |
| 107 |
|
| 108 |
@plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ all => 1 }); |
| 109 |
@names = map { $_->get_metadata()->{'name'} } @plugins; |
| 110 |
is( scalar grep( /^Test Plugin$/, @names), 1, "With all param, GetPlugins found disabled Test Plugin" ); |
| 111 |
|
| 98 |
for my $pass ( 1 .. 2 ) { |
112 |
for my $pass ( 1 .. 2 ) { |
| 99 |
my $plugins_dir; |
113 |
my $plugins_dir; |
| 100 |
my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink'; |
114 |
my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink'; |
| 101 |
- |
|
|