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