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