Bug 21073: (QA follow-up) Fix plugin-related tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 19 Jun 2019 18:38:20 +0000 (15:38 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 20 Jun 2019 07:35:46 +0000 (08:35 +0100)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/ImportBatch.t
t/db_dependent/Koha/REST/Plugin/PluginRoutes.t
t/db_dependent/Koha/Template/Plugin/KohaPlugins.t

index bcc25ef..676d2fd 100644 (file)
@@ -188,7 +188,10 @@ subtest "RecordsFromMarcPlugin" => sub {
 
     t::lib::Mocks::mock_config( 'enable_plugins', 1 );
     t::lib::Mocks::mock_preference( 'UseKohaPlugins', 1 );
-    my ($plugin) = Koha::Plugins->new->GetPlugins({ all => 1, metadata => { name => 'MarcFieldValues' } });
+
+    my $plugins = Koha::Plugins->new;
+    $plugins->InstallPlugins;
+    my ($plugin) = $plugins->GetPlugins({ all => 1, metadata => { name => 'MarcFieldValues' } });
     isnt( $plugin, undef, "Plugin found" );
     my $records = C4::ImportBatch::RecordsFromMarcPlugin( $name, ref $plugin, 'UTF-8' );
     is( @$records, 2, 'Two results returned' );
index cc50b56..197a28d 100644 (file)
@@ -50,7 +50,10 @@ subtest 'Bad plugins tests' => sub {
     t::lib::Mocks::mock_config( 'enable_plugins', 1 );
     t::lib::Mocks::mock_preference( 'UseKohaPlugins', 1 );
 
-    my @plugins = Koha::Plugins->new->GetPlugins( { all => 1 } );
+    my $plugins = Koha::Plugins->new;
+    $plugins->InstallPlugins;
+
+    my @plugins = $plugins->GetPlugins( { all => 1 } );
     foreach my $plugin (@plugins) {
         $plugin->enable;
     }
@@ -81,7 +84,10 @@ subtest 'Disabled plugins tests' => sub {
 
     my $good_plugin;
 
-    my @plugins = Koha::Plugins->new->GetPlugins( { all => 1 } );
+    my $plugins = Koha::Plugins->new;
+    $plugins->InstallPlugins;
+
+    my @plugins = $plugins->GetPlugins( { all => 1 } );
     foreach my $plugin (@plugins) {
         $plugin->disable;
         $good_plugin = $plugin
index 5ecc1cd..f0ff5b3 100755 (executable)
@@ -31,7 +31,9 @@ my $schema = Koha::Database->new->schema;
 $schema->storage->txn_begin;
 
 # Enable all plugins
-my @plugins = Koha::Plugins->new->GetPlugins({ all => 1, class => 'Koha::Plugin::Test' });
+my $plugins = Koha::Plugins->new;
+$plugins->InstallPlugins;
+my @plugins = $plugins->GetPlugins({ all => 1, class => 'Koha::Plugin::Test' });
 map { $_->enable; } @plugins;
 
 my $mock_plugin = Test::MockModule->new( 'Koha::Plugin::Test' );