stop using Moo as a test package
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_plugin.t
CommitLineData
836e1134 1use strict;
2use warnings;
3
62b6b631 4use Test::More;
836e1134 5
6use lib 't/lib';
7
8{
9
10 package Faux::Plugin;
11
06400669 12 sub new { bless { count => 1 }, shift }
13 sub count { shift->{count}++ }
836e1134 14}
15
d6ce7d52 16my $warnings = 0;
17
18use PluginTestApp;
7e114dd4 19my $logger = Class::MOP::Class->create_anon_class(
20 methods => {
6b4ae531 21 error => sub {0},
22 debug => sub {0},
23 info => sub {0},
7e114dd4 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;
33PluginTestApp->log($logger);
d6ce7d52 34
836e1134 35use Catalyst::Test qw/PluginTestApp/;
36
37ok( get("/compile_time_plugins"), "get ok" );
d6ce7d52 38is( $warnings, 0, 'no warnings' );
6b2a933b 39# FIXME - Run time plugin support is insane, and should be removed
40# for Catalyst 5.9
836e1134 41ok( get("/run_time_plugins"), "get ok" );
d0d4d785 42
6b4ae531 43local $ENV{CATALYST_DEBUG} = 0;
44
d6ce7d52 45is( $warnings, 1, '1 warning' );
46
d0d4d785 47use_ok 'TestApp';
48my @expected = qw(
49 Catalyst::Plugin::Test::Errors
50 Catalyst::Plugin::Test::Headers
d13a7137 51 Catalyst::Plugin::Test::Inline
3d101ef9 52 Catalyst::Plugin::Test::MangleDollarUnderScore
d0d4d785 53 Catalyst::Plugin::Test::Plugin
79d000eb 54 TestApp::Plugin::AddDispatchTypes
d0d4d785 55 TestApp::Plugin::FullyQualified
56);
57
58# Faux::Plugin is no longer reported
59is_deeply [ TestApp->registered_plugins ], \@expected,
60 'registered_plugins() should only report the plugins for the current class';
6b4ae531 61
62b6b631 62done_testing;