File: deprecated.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (40 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use strict;
use warnings;
use FindBin qw/$Bin/;
use lib "$Bin/lib";
use Test::More tests => 4;

my $warnings;
BEGIN { # Do this at compile time in case we generate a warning when use
        # DeprecatedTestApp
    $SIG{__WARN__} = sub {
        $warnings++ if $_[0] =~ /uses NEXT, which is deprecated/;
        $warnings++ if $_[0] =~ /trying to use NEXT, which is deprecated/;
    };
}
use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
my $mvc_warnings;
BEGIN {
    my $logger = Class::MOP::Class->create_anon_class(
    methods => {
        debug => sub {0},
        info  => sub {0},
        warn => sub {
            if ($_[1] =~ /switch your class names/) {
               $mvc_warnings++;
                return;
            }
            die "Caught unexpected warning: " . $_[1];
        },
    },
)->new_object;
    Catalyst->log($logger);
}

use Catalyst::Test 'DeprecatedTestApp';
is( $mvc_warnings, 1, 'Get the ::MVC:: warning' );

ok( my $response = request('http://localhost/'), 'Request' );
is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' );

is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');