Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / t / live / engine / response / cookies.t
CommitLineData
dd4e6fd2 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/../../lib";
8
c20bd9d9 9use Test::More tests => 10;
dd4e6fd2 10use Catalyst::Test 'TestApp';
11
12use HTTP::Headers::Util 'split_header_words';
13
fbcc39ad 14my $expected = {
15 Catalyst => [qw( Catalyst Cool path / )],
16 Cool => [qw( Cool Catalyst path / )]
dd4e6fd2 17};
18
19{
fbcc39ad 20 ok( my $response = request('http://localhost/engine/response/cookies/one'),
21 'Request' );
dd4e6fd2 22 ok( $response->is_success, 'Response Successful 2xx' );
23 is( $response->content_type, 'text/plain', 'Response Content-Type' );
fbcc39ad 24 is( $response->header('X-Catalyst-Action'),
25 'engine/response/cookies/one', 'Test Action' );
dd4e6fd2 26
27 my $cookies = {};
28
29 for my $cookie ( split_header_words( $response->header('Set-Cookie') ) ) {
30 $cookies->{ $cookie->[0] } = $cookie;
31 }
32
33 is_deeply( $cookies, $expected, 'Response Cookies' );
34}
35
36{
fbcc39ad 37 ok( my $response = request('http://localhost/engine/response/cookies/two'),
38 'Request' );
dd4e6fd2 39 ok( $response->is_redirect, 'Response Redirection 3xx' );
40 is( $response->code, 302, 'Response Code' );
fbcc39ad 41 is( $response->header('X-Catalyst-Action'),
42 'engine/response/cookies/two', 'Test Action' );
dd4e6fd2 43
44 my $cookies = {};
45
46 for my $cookie ( split_header_words( $response->header('Set-Cookie') ) ) {
47 $cookies->{ $cookie->[0] } = $cookie;
48 }
49
50 is_deeply( $cookies, $expected, 'Response Cookies' );
51}