Bug 22709: (RM follow-up) Clean up plugin tests
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 12 Jul 2019 10:45:25 +0000 (11:45 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 15 Jul 2019 10:23:10 +0000 (11:23 +0100)
The plugin tests were failing due to failed rollbacks and run order.
This patch moves them into their own directory and adds a reset test to
restore the original state of the plugin system after the tests have
run.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t [moved from t/db_dependent/Plugins/Biblio_and_Items_plugin_hooks.t with 98% similarity]
t/db_dependent/Koha/Plugins/KitchenSinkPlugin.kpz [moved from t/db_dependent/KitchenSinkPlugin.kpz with 100% similarity]
t/db_dependent/Koha/Plugins/Plugins.t [moved from t/db_dependent/Plugins.t with 98% similarity]
t/db_dependent/Koha/Plugins/z_reset.t [new file with mode: 0644]

@@ -28,7 +28,7 @@ use t::lib::TestBuilder;
 
 BEGIN {
     # Mock pluginsdir before loading Plugins module
-    my $path = dirname(__FILE__) . '/../../lib';
+    my $path = dirname(__FILE__) . '/../../../lib';
     t::lib::Mocks::mock_config( 'pluginsdir', $path );
 
     use_ok('Koha::Plugins');
similarity index 98%
rename from t/db_dependent/Plugins.t
rename to t/db_dependent/Koha/Plugins/Plugins.t
index 052b7ea..178c544 100755 (executable)
@@ -35,7 +35,7 @@ use t::lib::Mocks;
 
 BEGIN {
     # Mock pluginsdir before loading Plugins module
-    my $path = dirname(__FILE__) . '/../lib';
+    my $path = dirname(__FILE__) . '/../../../lib';
     t::lib::Mocks::mock_config( 'pluginsdir', $path );
 
     use_ok('Koha::Plugins');
@@ -297,6 +297,10 @@ subtest 'bundle_path() tests' => sub {
     my @current_dir = File::Spec->splitdir(abs_path(__FILE__));
     # remote Plugins.t
     pop @current_dir;
+    # remove /Plugins
+    pop @current_dir;
+    # remove /Koha
+    pop @current_dir;
     # remove db_dependent
     pop @current_dir;
 
diff --git a/t/db_dependent/Koha/Plugins/z_reset.t b/t/db_dependent/Koha/Plugins/z_reset.t
new file mode 100644 (file)
index 0000000..302873a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+use C4::Context;
+use Koha::Plugins;
+use Koha::Plugins::Methods;
+
+use Test::More tests => 1;
+
+my $plugins = Koha::Plugins->new()->InstallPlugins;
+
+ok( 1, 'Plugins reset' );
+
+1;