include test for failure mode
[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;
8use Test::MockObject;
9
10my $warnings;
11BEGIN { # Do this at compile time in case we generate a warning when use
12 # DeprecatedTestApp
13 $SIG{__WARN__} = sub { $warnings++ if $_[0] =~ /trying to use NEXT/ };
14}
15use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
16my $mvc_warnings;
17BEGIN {
18 my $logger = Test::MockObject->new;
19 $logger->mock('warn', sub { $mvc_warnings++ if $_[1] =~ /switch your class names/ });
20 Catalyst->log($logger);
21}
22
23use Catalyst::Test 'DeprecatedTestApp';
24is( $mvc_warnings, 1, 'Get the ::MVC:: warning' );
25
26ok( my $response = request('http://localhost/'), 'Request' );
27is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' );
28
d07c427a 29SKIP: {
30 skip 'non-dev release', 1 unless Catalyst::_IS_DEVELOPMENT_VERSION();
31 is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');
32}