diff options
Diffstat (limited to 'rt/t/shredder/03plugin.t')
-rw-r--r-- | rt/t/shredder/03plugin.t | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/rt/t/shredder/03plugin.t b/rt/t/shredder/03plugin.t new file mode 100644 index 000000000..190f40acf --- /dev/null +++ b/rt/t/shredder/03plugin.t @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +use Test::Deep; +use File::Spec; +use Test::More tests => 28; +use RT::Test (); +BEGIN { + my $shredder_utils = RT::Test::get_relocatable_file('utils.pl', + File::Spec->curdir()); + require $shredder_utils; +} + +my @PLUGINS = sort qw(Attachments Base Objects SQLDump Summary Tickets Users); + +use_ok('RT::Shredder::Plugin'); +{ + my $plugin = new RT::Shredder::Plugin; + isa_ok($plugin, 'RT::Shredder::Plugin'); + my %plugins = $plugin->List; + cmp_deeply( [sort keys %plugins], [@PLUGINS], "correct plugins" ); +} +{ # test ->List as class method + my %plugins = RT::Shredder::Plugin->List; + cmp_deeply( [sort keys %plugins], [@PLUGINS], "correct plugins" ); +} +{ # reblessing on LoadByName + foreach (@PLUGINS) { + my $plugin = new RT::Shredder::Plugin; + isa_ok($plugin, 'RT::Shredder::Plugin'); + my ($status, $msg) = $plugin->LoadByName( $_ ); + ok($status, "loaded plugin by name") or diag("error: $msg"); + isa_ok($plugin, "RT::Shredder::Plugin::$_" ); + } +} +{ # error checking in LoadByName + my $plugin = new RT::Shredder::Plugin; + isa_ok($plugin, 'RT::Shredder::Plugin'); + my ($status, $msg) = $plugin->LoadByName; + ok(!$status, "not loaded plugin - empty name"); + ($status, $msg) = $plugin->LoadByName('Foo'); + ok(!$status, "not loaded plugin - not exist"); +} + |