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