Commit | Line | Data |
19a24dbb |
1 | use strict; |
2 | use warnings; |
3 | use FindBin qw/$Bin/; |
4 | use lib "$Bin/lib"; |
5 | use Test::More tests => 4; |
19a24dbb |
6 | |
7 | my $warnings; |
8 | BEGIN { # 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 | } |
15 | use Catalyst; # Cause catalyst to be used so I can fiddle with the logging. |
16 | my $mvc_warnings; |
17 | BEGIN { |
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 | |
34 | use Catalyst::Test 'DeprecatedTestApp'; |
35 | is( $mvc_warnings, 1, 'Get the ::MVC:: warning' ); |
36 | |
37 | ok( my $response = request('http://localhost/'), 'Request' ); |
38 | is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' ); |
39 | |
67788976 |
40 | is( $warnings, 1, 'Got one and only one Adopt::NEXT warning'); |