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=65166dccf4faf908d1909453640bb2c5dffd4421;hp=01a19faad22ddd53715aab157276022102445afd;hb=2f3812528068bc1d9f7840067f0c03d36cd47e6d;hpb=afb82794328ff8da1efc0a4c37f3f3703c262c31 diff --git a/t/live_engine_request_uri.t b/t/live_engine_request_uri.t index 01a19fa..65166dc 100644 --- a/t/live_engine_request_uri.t +++ b/t/live_engine_request_uri.t @@ -1,12 +1,10 @@ -#!perl - use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::More tests => 49; +use Test::More tests => 66; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -120,3 +118,36 @@ SKIP: is( $response->header( 'X-Catalyst-warnings' ), 0, 'no warnings emitted' ); } +# more tests with undef - should be ignored +{ + my $uri = "http://localhost/engine/request/uri/uri_with_undef_only"; + ok( my $response = request($uri), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-uri-with' ), $uri, 'uri_with ok' ); + + # try with existing param + $uri = "$uri?x=1"; + ok( $response = request($uri), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-uri-with' ), $uri, 'uri_with ok' ); +} + +{ + my $uri = "http://localhost/engine/request/uri/uri_with_undef_ignore"; + ok( my $response = request($uri), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-uri-with' ), "${uri}?a=1", 'uri_with ok' ); + + # remove an existing param + ok( $response = request("${uri}?b=1"), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-uri-with' ), "${uri}?a=1", 'uri_with ok' ); + + # remove an existing param, leave one, and add a new one + ok( $response = request("${uri}?b=1&c=1"), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' ); + ok( !defined $response->header( 'X-Catalyst-Param-b' ),'param "b" ok' ); + is( $response->header( 'X-Catalyst-Param-c' ), '1', 'param "c" ok' ); +} +