File: unit_core_plugin.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (62 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use strict;
use warnings;

use Test::More;

use lib 't/lib';

{

    package Faux::Plugin;

    sub new { bless { count => 1 }, shift }
    sub count { shift->{count}++ }
}

my $warnings = 0;

use PluginTestApp;
my $logger = Class::MOP::Class->create_anon_class(
    methods => {
        error => sub {0},
        debug => sub {0},
        info => sub {0},
        warn => sub {
            if ($_[1] =~ /plugin method is deprecated/) {
               $warnings++;
                return;
            }
            die "Caught unexpected warning: " . $_[1];
        },
    },
)->new_object;
PluginTestApp->log($logger);

use Catalyst::Test qw/PluginTestApp/;

ok( get("/compile_time_plugins"), "get ok" );
is( $warnings, 0, 'no warnings' );
# FIXME - Run time plugin support is insane, and should be removed
#         for Catalyst 5.9
ok( get("/run_time_plugins"),     "get ok" );

local $ENV{CATALYST_DEBUG} = 0;

is( $warnings, 1, '1 warning' );

use_ok 'TestApp';
my @expected = qw(
  Catalyst::Plugin::Test::Errors
  Catalyst::Plugin::Test::Headers
  Catalyst::Plugin::Test::Inline
  Catalyst::Plugin::Test::MangleDollarUnderScore
  Catalyst::Plugin::Test::Plugin
  TestApp::Plugin::AddDispatchTypes
  TestApp::Plugin::FullyQualified
);

# Faux::Plugin is no longer reported
is_deeply [ TestApp->registered_plugins ], \@expected,
  'registered_plugins() should only report the plugins for the current class';

done_testing;