[Catalyst-commits] r9354 - in Catalyst-Runtime/5.80/trunk: . lib t
t/lib t/lib/Catalyst/Plugin/Test t/lib/DeprecatedTestApp
t/lib/DeprecatedTestApp/C
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Feb 20 00:24:36 GMT 2009
Author: t0m
Date: 2009-02-20 00:24:36 +0000 (Fri, 20 Feb 2009)
New Revision: 9354
Added:
Catalyst-Runtime/5.80/trunk/t/deprecated.t
Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Deprecated.pm
Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp.pm
Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/
Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/
Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/TODO
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Plugin.pm
Log:
Fix my retardedness with ::MVC:: warning having no conditional. Pull all the stuff which warns out into its own app so that the test suite is less shouty
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2009-02-20 00:24:26 UTC (rev 9353)
+++ Catalyst-Runtime/5.80/trunk/Changes 2009-02-20 00:24:36 UTC (rev 9354)
@@ -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
Modified: Catalyst-Runtime/5.80/trunk/TODO
===================================================================
--- Catalyst-Runtime/5.80/trunk/TODO 2009-02-20 00:24:26 UTC (rev 9353)
+++ Catalyst-Runtime/5.80/trunk/TODO 2009-02-20 00:24:36 UTC (rev 9354)
@@ -11,11 +11,6 @@
- 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!).
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-02-20 00:24:26 UTC (rev 9353)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-02-20 00:24:36 UTC (rev 9354)
@@ -2051,7 +2051,7 @@
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 ) {
Added: Catalyst-Runtime/5.80/trunk/t/deprecated.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/deprecated.t (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/deprecated.t 2009-02-20 00:24:36 UTC (rev 9354)
@@ -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');
Added: Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Deprecated.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Deprecated.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Deprecated.pm 2009-02-20 00:24:36 UTC (rev 9354)
@@ -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;
Modified: Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Plugin.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Plugin.pm 2009-02-20 00:24:26 UTC (rev 9353)
+++ Catalyst-Runtime/5.80/trunk/t/lib/Catalyst/Plugin/Test/Plugin.pm 2009-02-20 00:24:36 UTC (rev 9354)
@@ -13,18 +13,13 @@
$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
Added: Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm 2009-02-20 00:24:36 UTC (rev 9354)
@@ -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;
Added: Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp.pm 2009-02-20 00:24:36 UTC (rev 9354)
@@ -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;
More information about the Catalyst-commits
mailing list