From: Tomas Doran Date: Fri, 20 Feb 2009 00:24:36 +0000 (+0000) Subject: Fix my retardedness with ::MVC:: warning having no conditional. Pull all the stuff... X-Git-Tag: 5.80001~85 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=19a24dbb5b7329841b77ce80102c85c6bb137dee;hp=2d9f9c8d29a7dc0c8c72458d04eb44f9fc2d8396 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 --- diff --git a/Changes b/Changes index 3f37689..e6e66c9 100644 --- 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 --- 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!). diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8805134..37c06d1 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -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 index 0000000..f199082 --- /dev/null +++ b/t/deprecated.t @@ -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 index 0000000..a9552da --- /dev/null +++ b/t/lib/Catalyst/Plugin/Test/Deprecated.pm @@ -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; diff --git a/t/lib/Catalyst/Plugin/Test/Plugin.pm b/t/lib/Catalyst/Plugin/Test/Plugin.pm index 5cb6e4a..09ee8f7 100644 --- a/t/lib/Catalyst/Plugin/Test/Plugin.pm +++ b/t/lib/Catalyst/Plugin/Test/Plugin.pm @@ -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 index 0000000..b3ae86b --- /dev/null +++ b/t/lib/DeprecatedTestApp.pm @@ -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 index 0000000..7b8b74f --- /dev/null +++ b/t/lib/DeprecatedTestApp/C/Root.pm @@ -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;