X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=1a15f9f7f9a7d2272be8046e301fa3b24a46a0a6;hb=fb34eb9c063c53abd061d260a30f0ca7c57a0833;hp=cf05f5ff56e5d0bd1f0f66a51fab2158ccc5ca83;hpb=a1791811465a12062122c0bf4cb73c56a5d5fad2;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index cf05f5f..1a15f9f 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -27,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, @_ ) }; } @@ -107,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}; @@ -200,6 +206,9 @@ method and the L 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 object. Accepts an optional hashref for request @@ -225,10 +234,13 @@ sub local_request { my $app = shift; my $request = Catalyst::Utils::request(shift); - _customize_request($request, @_); + my %extra_env; + _customize_request($request, \%extra_env, @_); my $ret; - test_psgi app => $app, client => sub { $ret = shift->($request) }; + test_psgi + app => sub { $app->({ %{ $_[0] }, %extra_env }) }, + client => sub { $ret = shift->($request) }; return $ret; } @@ -303,11 +315,16 @@ sub remote_request { sub _customize_request { my $request = shift; + my $extra_env = shift; my $opts = pop(@_) || {}; $opts = {} unless ref($opts) eq 'HASH'; if ( my $host = exists $opts->{host} ? $opts->{host} : $default_host ) { $request->header( 'Host' => $host ); } + + if (my $extra = $opts->{extra_env}) { + @{ $extra_env }{keys %{ $extra }} = values %{ $extra }; + } } =head2 action_ok