5 use lib "$FindBin::Bin/../lib";
8 use Catalyst::Test 'TestApp';
9 use HTTP::Headers::Util 'split_header_words';
12 catalyst => [qw|catalyst cool path /bah|],
13 cool => [qw|cool catalyst path /|]
17 ok( my $response = request('http://localhost/engine/response/cookies/one'),
19 ok( $response->is_success, 'Response Successful 2xx' );
20 is( $response->content_type, 'text/plain', 'Response Content-Type' );
21 is( $response->header('X-Catalyst-Action'),
22 'engine/response/cookies/one', 'Test Action' );
26 for my $string ( $response->header('Set-Cookie') ) {
27 my $cookie = [ split_header_words $string];
28 $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
31 is_deeply( $cookies, $expected, 'Response Cookies' );
35 ok( my $response = request('http://localhost/engine/response/cookies/two'),
37 ok( $response->is_redirect, 'Response Redirection 3xx' );
38 is( $response->code, 302, 'Response Code' );
39 is( $response->header('X-Catalyst-Action'),
40 'engine/response/cookies/two', 'Test Action' );
44 for my $string ( $response->header('Set-Cookie') ) {
45 my $cookie = [ split_header_words $string];
46 $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
49 is_deeply( $cookies, $expected, 'Response Cookies' );
53 ok( my $response = request('http://localhost/engine/response/cookies/three'),
55 ok( $response->is_success, 'Response Successful 2xx' );
56 is( $response->content_type, 'text/plain', 'Response Content-Type' );
57 is( $response->header('X-Catalyst-Action'),
58 'engine/response/cookies/three', 'Test Action' );
62 for my $string ( $response->header('Set-Cookie') ) {
63 my $cookie = [ split_header_words $string];
64 $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
67 is_deeply( $cookies, {
68 hash => [ qw(hash a&b&c path /) ],
69 this_is_the_real_name => [ qw(this_is_the_real_name foo&bar path /) ], # not "object"
70 }, 'Response Cookies' );
75 ok( $response = request('http://localhost/engine/response/cookies/four'),
77 ok( $response->is_success, 'Response Successful 2xx' ) or diag explain $response;
78 is( $response->content_type, 'text/plain', 'Response Content-Type' );
79 is( $response->header('X-Catalyst-Action'),
80 'engine/response/cookies/four', 'Test Action' );
84 for my $string ( $response->header('Set-Cookie') ) {
85 my $cookie = [ split_header_words $string];
86 $cookies->{ $cookie->[0]->[0] } = $cookie->[0];
89 is_deeply( $cookies, {
90 good => [qw|good good_cookie path /|],
91 }, 'Response Cookies' );