From: Tomas Doran Date: Thu, 21 May 2009 20:13:14 +0000 (+0000) Subject: Tests for %ENV fail in Catalyst::Test X-Git-Tag: 5.80005~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e74b3d5cd6904c3e35f17711f14d66d43294f18f Tests for %ENV fail in Catalyst::Test --- diff --git a/t/aggregate/live_engine_request_env.t b/t/aggregate/live_engine_request_env.t new file mode 100644 index 0000000..fdf980b --- /dev/null +++ b/t/aggregate/live_engine_request_env.t @@ -0,0 +1,47 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use vars qw/ + $EXPECTED_ENV_VAR + $EXPECTED_ENV_VAL +/; + +BEGIN { + $EXPECTED_ENV_VAR = "CatalystTest$$"; + $EXPECTED_ENV_VAL = $ENV{$EXPECTED_ENV_VAR} + = "Test env value " . rand(100000); +} + +use Test::More tests => 7; +use Catalyst::Test 'TestApp'; + +use Catalyst::Request; +use HTTP::Headers; +use HTTP::Request::Common; + +{ + my $env; + + ok( my $response = request("http://localhost/dump/env"), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + ok( eval '$env = ' . $response->content, 'Unserialize Catalyst::Request' ); + is ref($env), 'HASH'; + ok exists($env->{PATH}), 'Have a PATH env var'; + + SKIP: + { + if ( $ENV{CATALYST_SERVER} ) { + skip 'Using remote server', 1; + } + is $env->{$EXPECTED_ENV_VAR}, $EXPECTED_ENV_VAL, + 'Value we set as expected'; + } +} + diff --git a/t/lib/TestApp/Controller/Dump.pm b/t/lib/TestApp/Controller/Dump.pm index 5ea9423..fcbdc5e 100644 --- a/t/lib/TestApp/Controller/Dump.pm +++ b/t/lib/TestApp/Controller/Dump.pm @@ -10,7 +10,7 @@ sub default : Action Private { sub env : Action Relative { my ( $self, $c ) = @_; - $c->forward('TestApp::View::Dump', [\%ENV]); + $c->forward('TestApp::View::Dump::Env'); } sub request : Action Relative { diff --git a/t/lib/TestApp/View/Dump/Env.pm b/t/lib/TestApp/View/Dump/Env.pm new file mode 100644 index 0000000..0acd1df --- /dev/null +++ b/t/lib/TestApp/View/Dump/Env.pm @@ -0,0 +1,12 @@ +package TestApp::View::Dump::Env; + +use strict; +use base qw[TestApp::View::Dump]; + +sub process { + my ( $self, $c ) = @_; + return $self->SUPER::process( $c, $c->engine->env ); +} + +1; +