Remove Test::MockObject
[catagits/Catalyst-Runtime.git] / t / unit_core_plugin.t
CommitLineData
836e1134 1#!/usr/bin/perl
2
3use strict;
4use warnings;
d6ce7d52 5use Test::MockObject::Extends;
836e1134 6
d6ce7d52 7use Test::More tests => 24;
836e1134 8
9use lib 't/lib';
10
11{
12
13 package Faux::Plugin;
14
15 sub new { bless {}, shift }
16 my $count = 1;
17 sub count { $count++ }
18}
19
d6ce7d52 20my $warnings = 0;
21
22use PluginTestApp;
23my $logger = Test::MockObject::Extends->new(PluginTestApp->log);
24$logger->mock('warn', sub {
25 if ($_[1] =~ /plugin method is deprecated/) {
26 $warnings++;
27 return;
28 }
29 die "Caught unexpected warning: " . $_[1];
30});
31#PluginTestApp->log($logger);
32
836e1134 33use Catalyst::Test qw/PluginTestApp/;
34
35ok( get("/compile_time_plugins"), "get ok" );
d6ce7d52 36is( $warnings, 0, 'no warnings' );
6b2a933b 37# FIXME - Run time plugin support is insane, and should be removed
38# for Catalyst 5.9
836e1134 39ok( get("/run_time_plugins"), "get ok" );
d0d4d785 40
d6ce7d52 41is( $warnings, 1, '1 warning' );
42
d0d4d785 43use_ok 'TestApp';
44my @expected = qw(
45 Catalyst::Plugin::Test::Errors
46 Catalyst::Plugin::Test::Headers
d13a7137 47 Catalyst::Plugin::Test::Inline
3d101ef9 48 Catalyst::Plugin::Test::MangleDollarUnderScore
d0d4d785 49 Catalyst::Plugin::Test::Plugin
79d000eb 50 TestApp::Plugin::AddDispatchTypes
d0d4d785 51 TestApp::Plugin::FullyQualified
52);
53
54# Faux::Plugin is no longer reported
55is_deeply [ TestApp->registered_plugins ], \@expected,
56 'registered_plugins() should only report the plugins for the current class';