Fixed path, can now be changed properly, also updated test for this
[catagits/Catalyst-Runtime.git] / t / live / engine / request / uri.t
1 #!perl\r
2 \r
3 use strict;\r
4 use warnings;\r
5 \r
6 use FindBin;\r
7 use lib "$FindBin::Bin/../../lib";\r
8 \r
9 use Test::More tests => 18;\r
10 use Catalyst::Test 'TestApp';\r
11 use Catalyst::Request;\r
12 \r
13 my $creq;\r
14 \r
15 # test that the path can be changed\r
16 {\r
17     ok( my $response = request('http://localhost/engine/request/uri/change_path'), 'Request' );\r
18     ok( $response->is_success, 'Response Successful 2xx' );\r
19     ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );\r
20     like( $creq->uri, qr{/my/app/lives/here$}, 'URI contains new path' );\r
21 }\r
22 \r
23 # test that path properly removes the base location\r
24 {\r
25     ok( my $response = request('http://localhost/engine/request/uri/change_base'), 'Request' );\r
26     ok( $response->is_success, 'Response Successful 2xx' );\r
27     ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );\r
28     like( $creq->base, qr{/new/location}, 'Base URI contains new location' );\r
29     is( $creq->path, 'engine/request/uri/change_base', 'URI contains correct path' );\r
30 }\r
31 \r
32 # test that base + path is correct\r
33 {\r
34     ok( my $response = request('http://localhost/engine/request/uri'), 'Request' );\r
35     ok( $response->is_success, 'Response Successful 2xx' );\r
36     ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );\r
37     is( $creq->base . $creq->path, $creq->uri, 'Base + Path ok' );\r
38 }\r
39 \r
40 # test that we can use semi-colons as separators\r
41 {\r
42     my $parameters = {\r
43         a => [ qw/1 2/ ],\r
44         b => 3,\r
45     };\r
46     \r
47     ok( my $response = request('http://localhost/engine/request/uri?a=1;a=2;b=3'), 'Request' );\r
48     ok( $response->is_success, 'Response Successful 2xx' );\r
49     ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );\r
50     is( $creq->{uri}->query, 'a=1;a=2;b=3', 'Query string ok' );\r
51     is_deeply( $creq->{parameters}, $parameters, 'Parameters ok' );\r
52 }    \r