preserve $c->state
[catagits/Catalyst-Runtime.git] / t / deprecated.t
index f199082..9e5579e 100644 (file)
@@ -1,22 +1,33 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 use FindBin qw/$Bin/;
 use lib "$Bin/lib";
 use Test::More tests => 4;
-use Test::MockObject;
 
 my $warnings;
 BEGIN { # Do this at compile time in case we generate a warning when use
         # DeprecatedTestApp
-    $SIG{__WARN__} = sub { $warnings++ if $_[0] =~ /trying to use NEXT/ };
+    $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 = Test::MockObject->new;
-    $logger->mock('warn', sub { $mvc_warnings++ if $_[1] =~ /switch your class names/ });
+    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);
 }