import rt 3.8.7
[freeside.git] / rt / t / shredder / 03plugin.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use warnings;
5
6 use Test::Deep;
7 use File::Spec;
8 use Test::More tests => 28;
9 use RT::Test ();
10 BEGIN {
11     my $shredder_utils = RT::Test::get_relocatable_file('utils.pl',
12         File::Spec->curdir());
13     require $shredder_utils;
14 }
15
16 my @PLUGINS = sort qw(Attachments Base Objects SQLDump Summary Tickets Users);
17
18 use_ok('RT::Shredder::Plugin');
19 {
20     my $plugin = new RT::Shredder::Plugin;
21     isa_ok($plugin, 'RT::Shredder::Plugin');
22     my %plugins = $plugin->List;
23     cmp_deeply( [sort keys %plugins], [@PLUGINS], "correct plugins" );
24 }
25 { # test ->List as class method
26     my %plugins = RT::Shredder::Plugin->List;
27     cmp_deeply( [sort keys %plugins], [@PLUGINS], "correct plugins" );
28 }
29 { # reblessing on LoadByName
30     foreach (@PLUGINS) {
31         my $plugin = new RT::Shredder::Plugin;
32         isa_ok($plugin, 'RT::Shredder::Plugin');
33         my ($status, $msg) = $plugin->LoadByName( $_ );
34         ok($status, "loaded plugin by name") or diag("error: $msg");
35         isa_ok($plugin, "RT::Shredder::Plugin::$_" );
36     }
37 }
38 { # error checking in LoadByName
39     my $plugin = new RT::Shredder::Plugin;
40     isa_ok($plugin, 'RT::Shredder::Plugin');
41     my ($status, $msg) = $plugin->LoadByName;
42     ok(!$status, "not loaded plugin - empty name");
43     ($status, $msg) = $plugin->LoadByName('Foo');
44     ok(!$status, "not loaded plugin - not exist");
45 }
46