Bug 16502: Add additional test to Plugins.t
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Mon, 16 May 2016 17:00:16 +0000 (19:00 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 7 Jul 2016 23:06:50 +0000 (11:06 +1200)
In order to verify if the delete now really works, we add one test
in Plugins.t.

Test plan:
[1] Run the test.
[2] Bonus: Comment line 63 in Plugins.t where delete is called.
    Run the test again. It should fail now.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 959d69fa0107423ed31e20f4a6afb46d1e5c771c)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
(cherry picked from commit 0632256c1aca919ec055dd5f170ac10d84cc8ec7)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
(cherry picked from commit e41863bfa9bf73066d2ec43a3b8e843fa1f0222f)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

t/db_dependent/Plugins.t

index 6cff239..308e215 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 21;
+use Test::More tests => 22;
 use File::Basename;
 use FindBin qw($Bin);
 use Archive::Extract;
@@ -47,8 +47,8 @@ ok( $plugins[0]->get_metadata()->{'name'} eq 'Test Plugin', "Koha::Plugins::GetP
 
 SKIP: {
     my $plugins_dir = C4::Context->config("pluginsdir");
-    skip "plugindir not set", 3 unless defined $plugins_dir;
-    skip "plugindir not writable", 3 unless -w $plugins_dir;
+    skip "plugindir not set", 4 unless defined $plugins_dir;
+    skip "plugindir not writable", 4 unless -w $plugins_dir;
     # no need to skip further tests if KitchenSink would already exist
 
     my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' );
@@ -57,8 +57,12 @@ SKIP: {
     }
     use_ok('Koha::Plugin::Com::ByWaterSolutions::KitchenSink');
     $plugin = Koha::Plugin::Com::ByWaterSolutions::KitchenSink->new({ enable_plugins => 1});
+    my $table = $plugin->get_qualified_table_name( 'mytable' );
 
     ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );
     Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 });
+    my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );
+    my $info = $sth->fetchall_arrayref;
+    is( @$info, 0, "Table $table does no longer exist" );
     ok( !( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm" ), "Koha::Plugins::Handler::delete works correctly." );
 }