update distar url
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_plugin.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib 't/lib';
7
8 {
9
10     package Faux::Plugin;
11
12     sub new { bless { count => 1 }, shift }
13     sub count { shift->{count}++ }
14 }
15
16 my $warnings = 0;
17
18 use PluginTestApp;
19 my $logger = Class::MOP::Class->create_anon_class(
20     methods => {
21         error => sub {0},
22         debug => sub {0},
23         info => sub {0},
24         warn => sub {
25             if ($_[1] =~ /plugin method is deprecated/) {
26                $warnings++;
27                 return;
28             }
29             die "Caught unexpected warning: " . $_[1];
30         },
31     },
32 )->new_object;
33 PluginTestApp->log($logger);
34
35 use Catalyst::Test qw/PluginTestApp/;
36
37 ok( get("/compile_time_plugins"), "get ok" );
38 is( $warnings, 0, 'no warnings' );
39 # FIXME - Run time plugin support is insane, and should be removed
40 #         for Catalyst 5.9
41 ok( get("/run_time_plugins"),     "get ok" );
42
43 local $ENV{CATALYST_DEBUG} = 0;
44
45 is( $warnings, 1, '1 warning' );
46
47 use_ok 'TestApp';
48 my @expected = qw(
49   Catalyst::Plugin::Test::Errors
50   Catalyst::Plugin::Test::Headers
51   Catalyst::Plugin::Test::Inline
52   Catalyst::Plugin::Test::MangleDollarUnderScore
53   Catalyst::Plugin::Test::Plugin
54   TestApp::Plugin::AddDispatchTypes
55   TestApp::Plugin::FullyQualified
56 );
57
58 # Faux::Plugin is no longer reported
59 is_deeply [ TestApp->registered_plugins ], \@expected,
60   'registered_plugins() should only report the plugins for the current class';
61
62 done_testing;