X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=trunk%2Ft%2Faggregate%2Flive_engine_response_cookies.t;fp=trunk%2Ft%2Faggregate%2Flive_engine_response_cookies.t;h=5f2f2266c6605e7e2a428a5ad461af31615dd61e;hb=e28a6876ad3e11890226e5bab6df4b0725e0981e;hp=0000000000000000000000000000000000000000;hpb=21c94d83082b43028cafcfb18659090b13d832fa;p=catagits%2FCatalyst-Runtime.git diff --git a/trunk/t/aggregate/live_engine_response_cookies.t b/trunk/t/aggregate/live_engine_response_cookies.t new file mode 100644 index 0000000..5f2f226 --- /dev/null +++ b/trunk/t/aggregate/live_engine_response_cookies.t @@ -0,0 +1,73 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use Test::More tests => 15; +use Catalyst::Test 'TestApp'; +use HTTP::Headers::Util 'split_header_words'; + +my $expected = { + catalyst => [qw|catalyst cool path /bah|], + cool => [qw|cool catalyst path /|] +}; + +{ + ok( my $response = request('http://localhost/engine/response/cookies/one'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'engine/response/cookies/one', 'Test Action' ); + + my $cookies = {}; + + for my $string ( $response->header('Set-Cookie') ) { + my $cookie = [ split_header_words $string]; + $cookies->{ $cookie->[0]->[0] } = $cookie->[0]; + } + + is_deeply( $cookies, $expected, 'Response Cookies' ); +} + +{ + ok( my $response = request('http://localhost/engine/response/cookies/two'), + 'Request' ); + ok( $response->is_redirect, 'Response Redirection 3xx' ); + is( $response->code, 302, 'Response Code' ); + is( $response->header('X-Catalyst-Action'), + 'engine/response/cookies/two', 'Test Action' ); + + my $cookies = {}; + + for my $string ( $response->header('Set-Cookie') ) { + my $cookie = [ split_header_words $string]; + $cookies->{ $cookie->[0]->[0] } = $cookie->[0]; + } + + is_deeply( $cookies, $expected, 'Response Cookies' ); +} + +{ + ok( my $response = request('http://localhost/engine/response/cookies/three'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'engine/response/cookies/three', 'Test Action' ); + + my $cookies = {}; + + for my $string ( $response->header('Set-Cookie') ) { + my $cookie = [ split_header_words $string]; + $cookies->{ $cookie->[0]->[0] } = $cookie->[0]; + } + + is_deeply( $cookies, { + hash => [ qw(hash a&b&c path /) ], + this_is_the_real_name => [ qw(this_is_the_real_name foo&bar path /) ], # not "object" + }, 'Response Cookies' ); +}