X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive_engine_request_uri.t;h=dba622fd6bfdfeac82112a99d2a87579f650cbb1;hp=5af97f9a20886883f005d5a1d64efa340f7933ad;hb=5789a3d8e83afb0a0232d4f2a2617353497cd976;hpb=a2e038a1e9cbc0f1ea32b7087e6b47efe3af082f diff --git a/t/live_engine_request_uri.t b/t/live_engine_request_uri.t index 5af97f9..dba622f 100644 --- a/t/live_engine_request_uri.t +++ b/t/live_engine_request_uri.t @@ -1,4 +1,4 @@ -#!perl +#!perl use strict; use warnings; @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::More tests => 23; +use Test::More tests => 38; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -59,3 +59,34 @@ my $creq; is( $creq->{uri}->query, 'text=Catalyst%20Rocks', 'Query string ok' ); is( $creq->{parameters}->{text}, 'Catalyst Rocks', 'Unescaped param ok' ); } + +# test that uri_with adds params +{ + ok( my $response = request('http://localhost/engine/request/uri/uri_with'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + ok( !defined $response->header( 'X-Catalyst-Param-a' ), 'param "a" ok' ); + is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' ); +} + +# test that uri_with adds params (and preserves) +{ + ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' ); + is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' ); +} + +# test that uri_with replaces params (and preserves) +{ + ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1&b=2'), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' ); + is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' ); +} + +# test that uri_with is utf8 safe +{ + ok( my $response = request("http://localhost/engine/request/uri/uri_with_utf8"), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + like( $response->header( 'X-Catalyst-uri-with' ), qr/%E2%98%A0$/, 'uri_with ok' ); +}