Fixed path, can now be changed properly, also updated test for this
[catagits/Catalyst-Runtime.git] / t / live / engine / request / uri.t
CommitLineData
fbcc39ad 1#!perl\r
2\r
3use strict;\r
4use warnings;\r
5\r
6use FindBin;\r
7use lib "$FindBin::Bin/../../lib";\r
8\r
9use Test::More tests => 18;\r
10use Catalyst::Test 'TestApp';\r
11use Catalyst::Request;\r
12\r
13my $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
79f8efb8 20 like( $creq->uri, qr{/my/app/lives/here$}, 'URI contains new path' );\r
fbcc39ad 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