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