Detect redispatch exceptions by a class check, not by checking the exception message.
[catagits/Catalyst-Runtime.git] / t / unit_core_plugin.t
CommitLineData
836e1134 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
d6ce7d52 6use Test::More tests => 24;
836e1134 7
8use lib 't/lib';
9
10{
11
12 package Faux::Plugin;
13
14 sub new { bless {}, shift }
15 my $count = 1;
16 sub count { $count++ }
17}
18
d6ce7d52 19my $warnings = 0;
20
21use PluginTestApp;
7e114dd4 22my $logger = Class::MOP::Class->create_anon_class(
23 methods => {
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
d6ce7d52 43is( $warnings, 1, '1 warning' );
44
d0d4d785 45use_ok 'TestApp';
46my @expected = qw(
47 Catalyst::Plugin::Test::Errors
48 Catalyst::Plugin::Test::Headers
d13a7137 49 Catalyst::Plugin::Test::Inline
3d101ef9 50 Catalyst::Plugin::Test::MangleDollarUnderScore
d0d4d785 51 Catalyst::Plugin::Test::Plugin
79d000eb 52 TestApp::Plugin::AddDispatchTypes
d0d4d785 53 TestApp::Plugin::FullyQualified
54);
55
56# Faux::Plugin is no longer reported
57is_deeply [ TestApp->registered_plugins ], \@expected,
58 'registered_plugins() should only report the plugins for the current class';