From: Tomas Doran Date: Mon, 11 Jan 2010 21:11:05 +0000 (+0000) Subject: Deprecate bare imports of Catalyst::Test - either use an app name or don't run the... X-Git-Tag: 5.80018~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=955d6da66d0a5c2f770d68d9b9e5b1bd22b21750 Deprecate bare imports of Catalyst::Test - either use an app name or don't run the import method. As-per r12564 --- diff --git a/Changes b/Changes index 1be1533..176d54d 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,11 @@ Documentation: - Clarify that uri_for_action works on private paths, with example. + Deprecations: + - Saying use Catalyst::Test; (without an application name or () to stop + the importer running is now deprecated and will issue a warning. + You should be saying use Catalyst::Test (); + 5.80017 2010-01-10 02:27:29 Documentation: diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index 8776803..f987172 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -103,6 +103,12 @@ our $default_host; sub import { my ($self, $class, $opts) = @_; + Carp::carp( +qq{Importing Catalyst::Test without an application name is deprecated:\n +Instead of saying: use Catalyst::Test; +say: use Catalyst::Test (); # If you don't want to import a test app right now. +or say: use Catalyst::Test 'MyApp'; # If you do want to import a test app.\n\n}) + unless $class; $import->($self, '-all' => { class => $class }); $opts = {} unless ref $opts eq 'HASH'; $default_host = $opts->{default_host} if exists $opts->{default_host}; diff --git a/t/aggregate/deprecated_test_import.t b/t/aggregate/deprecated_test_import.t new file mode 100644 index 0000000..ee90eea --- /dev/null +++ b/t/aggregate/deprecated_test_import.t @@ -0,0 +1,16 @@ +use strict; +use warnings; + +use Test::More; +use Catalyst::Test (); + +my $warn; +{ + local $SIG{__WARN__} = sub { $warn = shift; }; + Catalyst::Test->import(); +} +ok $warn; +like $warn, qr/deprecated/; + +done_testing; +