fixed reportred regression on auto actions
[catagits/Catalyst-Runtime.git] / t / deprecated.t
CommitLineData
19a24dbb 1use strict;
2use warnings;
3use FindBin qw/$Bin/;
4use lib "$Bin/lib";
5use Test::More tests => 4;
19a24dbb 6
7my $warnings;
8BEGIN { # Do this at compile time in case we generate a warning when use
9 # DeprecatedTestApp
2e7251d3 10 $SIG{__WARN__} = sub {
11 $warnings++ if $_[0] =~ /uses NEXT, which is deprecated/;
12c73fb2 12 $warnings++ if $_[0] =~ /trying to use NEXT, which is deprecated/;
2e7251d3 13 };
19a24dbb 14}
15use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
16my $mvc_warnings;
17BEGIN {
6a163489 18 my $logger = Class::MOP::Class->create_anon_class(
19 methods => {
6b4ae531 20 debug => sub {0},
21 info => sub {0},
6a163489 22 warn => sub {
23 if ($_[1] =~ /switch your class names/) {
24 $mvc_warnings++;
25 return;
26 }
27 die "Caught unexpected warning: " . $_[1];
28 },
29 },
30)->new_object;
19a24dbb 31 Catalyst->log($logger);
32}
33
34use Catalyst::Test 'DeprecatedTestApp';
35is( $mvc_warnings, 1, 'Get the ::MVC:: warning' );
36
37ok( my $response = request('http://localhost/'), 'Request' );
38is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' );
39
67788976 40is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');