Remove that idiocy
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Test.pm
index 821b6e3..1a15f9f 100644 (file)
@@ -5,7 +5,6 @@ use warnings;
 use Test::More ();
 
 use Plack::Test;
-use Plack::Middleware::OverrideEnv;
 use Catalyst::Exception;
 use Catalyst::Utils;
 use Class::MOP;
@@ -28,7 +27,7 @@ my $build_exports = sub {
         }
         $class->import;
 
-        my $app = $class->engine->_build_psgi_app($class);
+        my $app = $class->psgi_app;
 
         $request = sub { local_request( $app, @_ ) };
     }
@@ -108,6 +107,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};
@@ -201,6 +206,9 @@ method and the L<request|/"$res = request( ... );"> method below:
     is ( $uri->path , '/y');
     my $content = get($uri->path);
 
+Note also that the content is returned as raw bytes, without any attempt
+to decode it into characters.
+
 =head2 $res = request( ... );
 
 Returns an L<HTTP::Response> object. Accepts an optional hashref for request
@@ -231,12 +239,8 @@ sub local_request {
 
     my $ret;
     test_psgi
-        app => Plack::Middleware::OverrideEnv->wrap(
-            $app, env_override => \%extra_env,
-        ),
-        client => sub {
-            $ret = shift->($request);
-        };
+        app    => sub { $app->({ %{ $_[0] }, %extra_env }) },
+        client => sub { $ret = shift->($request) };
 
     return $ret;
 }