Fix my retardedness with ::MVC:: warning having no conditional. Pull all the stuff...
Tomas Doran [Fri, 20 Feb 2009 00:24:36 +0000 (00:24 +0000)]
Changes
TODO
lib/Catalyst.pm
t/deprecated.t [new file with mode: 0644]
t/lib/Catalyst/Plugin/Test/Deprecated.pm [new file with mode: 0644]
t/lib/Catalyst/Plugin/Test/Plugin.pm
t/lib/DeprecatedTestApp.pm [new file with mode: 0644]
t/lib/DeprecatedTestApp/C/Root.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index 3f37689..e6e66c9 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Move NEXT use and testing deprecated features out to its own
+          test application so that the main TestApp isn't polluted with
+          spurious warnings (t0m)
+        - Add a warning for the old ::[MVC]:: style naming scheme (t0m)
+          - Test for this (t0m)
         - Kill Class::C3::Adopt::NEXT warnings for the Catalyst:: namespace
           in production versions (t0m)
         - Make MyApp.pm restartable by unsetting setup_finished in
diff --git a/TODO b/TODO
index 03ae67f..f8d31ff 100644 (file)
--- a/TODO
+++ b/TODO
@@ -11,11 +11,6 @@ Documentation:
 
    - Run more smokes
 
-   - Using anything ::[CMV]:: should warn (once, on boot).
-
-   - TestApp should not use NEXT. There should be a TestAppNEXTCompat
-     which does but is standalone..
-
 Profiling:
 
   - vs 5.70 and optimisation as needed on perl 5.8 (5.10 is already faster!).
index 8805134..37c06d1 100644 (file)
@@ -2051,7 +2051,7 @@ sub setup_components {
     my $deprecated_component_names = grep { /::[CMV]::/ } @comps;
     $class->log->warn(qq{Your application is using the deprecated ::[MVC]:: type naming scheme.\n}.
         qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
-    );
+    ) if $deprecated_component_names;
 
     for my $component ( @comps ) {
 
diff --git a/t/deprecated.t b/t/deprecated.t
new file mode 100644 (file)
index 0000000..f199082
--- /dev/null
@@ -0,0 +1,29 @@
+#!/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/ };
+}
+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/ });
+    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');
diff --git a/t/lib/Catalyst/Plugin/Test/Deprecated.pm b/t/lib/Catalyst/Plugin/Test/Deprecated.pm
new file mode 100644 (file)
index 0000000..a9552da
--- /dev/null
@@ -0,0 +1,20 @@
+package Catalyst::Plugin::Test::Deprecated;
+
+use strict;
+use warnings;
+use NEXT;
+
+use base qw/Catalyst::Base/;
+
+sub prepare {
+    my $class = shift;
+    # Note: This use of NEXT is deliberately left here (without a use NEXT)
+    #       to ensure back compat, as NEXT always used to be loaded, but
+    #       is now replaced by Class::C3::Adopt::NEXT.
+    my $c = $class->NEXT::prepare(@_);
+    $c->response->header( 'X-Catalyst-Plugin-Deprecated' => 1 );
+
+    return $c;
+}
+
+1;
index 5cb6e4a..09ee8f7 100644 (file)
@@ -13,18 +13,13 @@ sub setup {
    $c->ran_setup('1');
 }
 
-sub  prepare {
-
+sub prepare {
     my $class = shift;
 
-# Note: This use of NEXT is deliberately left here (without a use NEXT)
-#       to ensure back compat, as NEXT always used to be loaded, but 
-#       is now replaced by Class::C3::Adopt::NEXT.
-    my $c = $class->NEXT::prepare(@_);
+    my $c = $class->next::method(@_);
     $c->response->header( 'X-Catalyst-Plugin-Setup' => $c->ran_setup );
 
     return $c;
-
 }
 
 # Note: This is horrible, but Catalyst::Plugin::Server forces the body to
diff --git a/t/lib/DeprecatedTestApp.pm b/t/lib/DeprecatedTestApp.pm
new file mode 100644 (file)
index 0000000..b3ae86b
--- /dev/null
@@ -0,0 +1,14 @@
+package DeprecatedTestApp;
+
+use strict;
+use Catalyst qw/
+    Test::Deprecated
+/;
+
+our $VERSION = '0.01';
+
+__PACKAGE__->config( name => 'DeprecatedTestApp', root => '/some/dir' );
+
+__PACKAGE__->setup;
+
+1;
diff --git a/t/lib/DeprecatedTestApp/C/Root.pm b/t/lib/DeprecatedTestApp/C/Root.pm
new file mode 100644 (file)
index 0000000..7b8b74f
--- /dev/null
@@ -0,0 +1,13 @@
+package DeprecatedTestApp::C::Root;
+use strict;
+use warnings;
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config->{namespace} = '';
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->body('root index');
+}
+
+1;