unmark +x and remove shebangs
[catagits/Catalyst-Runtime.git] / t / deprecated.t
1 use strict;
2 use warnings;
3 use FindBin qw/$Bin/;
4 use lib "$Bin/lib";
5 use Test::More tests => 4;
6
7 my $warnings;
8 BEGIN { # Do this at compile time in case we generate a warning when use
9         # DeprecatedTestApp
10     $SIG{__WARN__} = sub {
11         $warnings++ if $_[0] =~ /uses NEXT, which is deprecated/;
12         $warnings++ if $_[0] =~ /trying to use NEXT, which is deprecated/;
13     };
14 }
15 use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
16 my $mvc_warnings;
17 BEGIN {
18     my $logger = Class::MOP::Class->create_anon_class(
19     methods => {
20         debug => sub {0},
21         info  => sub {0},
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;
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
40 is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');