include test for failure mode
[catagits/Catalyst-Runtime.git] / t / deprecated.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use FindBin qw/$Bin/;
6 use lib "$Bin/lib";
7 use Test::More tests => 4;
8 use Test::MockObject;
9
10 my $warnings;
11 BEGIN { # 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 }
15 use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
16 my $mvc_warnings;
17 BEGIN {
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
23 use Catalyst::Test 'DeprecatedTestApp';
24 is( $mvc_warnings, 1, 'Get the ::MVC:: warning' );
25
26 ok( my $response = request('http://localhost/'), 'Request' );
27 is( $response->header('X-Catalyst-Plugin-Deprecated'), '1', 'NEXT plugin ran correctly' );
28
29 SKIP: {
30     skip 'non-dev release', 1 unless Catalyst::_IS_DEVELOPMENT_VERSION();
31     is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');
32 }