X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Faggregate%2Flive_engine_request_uri.t;h=5618e7c4a00dccd105c3abd057c1cca955b64175;hp=ee6fdfd0a24850421d533a0285c028a09bb47366;hb=480d94b5f34577816d44fe05389ca5a085179363;hpb=dae2b0faaf2982bde81606ea0392c13fd9309cb1 diff --git a/t/aggregate/live_engine_request_uri.t b/t/aggregate/live_engine_request_uri.t index ee6fdfd..5618e7c 100644 --- a/t/aggregate/live_engine_request_uri.t +++ b/t/aggregate/live_engine_request_uri.t @@ -4,7 +4,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; -use Test::More tests => 68; +use Test::More tests => 74; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -14,7 +14,8 @@ my $creq; { ok( my $response = request('http://localhost/engine/request/uri/change_path'), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); - ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ); + ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ) + or diag("Exception '$@', content " . $response->content); like( $creq->uri, qr{/my/app/lives/here$}, 'URI contains new path' ); } @@ -79,6 +80,8 @@ SKIP: 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' ); + is( $response->header( 'X-Catalyst-Param-c' ), '--notexists--', 'param "c" ok' ); + unlike($response->header ('X-Catalyst-query'), qr/c=/, 'no c in return'); } # test that uri_with adds params (and preserves) @@ -87,14 +90,18 @@ SKIP: 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' ); + is( $response->header( 'X-Catalyst-Param-c' ), '--notexists--', 'param "c" ok' ); + unlike($response->header ('X-Catalyst-query'), qr/c=/, 'no c in return'); } # 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( my $response = request('http://localhost/engine/request/uri/uri_with?a=1&b=2&c=3'), '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' ); + is( $response->header( 'X-Catalyst-Param-c' ), '--notexists--', 'param "c" deleted ok' ); + unlike($response->header ('X-Catalyst-query'), qr/c=/, 'no c in return'); } # test that uri_with replaces params (and preserves) @@ -121,27 +128,31 @@ SKIP: # more tests with undef - should be ignored { my $uri = "http://localhost/engine/request/uri/uri_with_undef_only"; + my ($check) = $uri =~ m{^http://localhost(.+)}; # needed to work with remote servers ok( my $response = request($uri), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'X-Catalyst-uri-with' ), $uri, 'uri_with ok' ); + like( $response->header( 'X-Catalyst-uri-with' ), qr/$check$/, 'uri_with ok' ); # try with existing param $uri = "$uri?x=1"; + ($check) = $uri =~ m{^http://localhost(.+)}; # needed to work with remote servers + $check =~ s/\?/\\\?/g; ok( $response = request($uri), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'X-Catalyst-uri-with' ), $uri, 'uri_with ok' ); + like( $response->header( 'X-Catalyst-uri-with' ), qr/$check$/, 'uri_with ok' ); } { my $uri = "http://localhost/engine/request/uri/uri_with_undef_ignore"; + my ($check) = $uri =~ m{^http://localhost(.+)}; # needed to work with remote servers 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' ); + like( $response->header( 'X-Catalyst-uri-with' ), qr/$check\?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' ); + like( $response->header( 'X-Catalyst-uri-with' ), qr/$check\?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' ); @@ -151,12 +162,16 @@ SKIP: is( $response->header( 'X-Catalyst-Param-c' ), '1', 'param "c" ok' ); } -SKIP: { - skip 'This currently causes infinite recursion', 2; +# Test an overridden uri method which calls the base method, SmartURI does this. +SKIP: +{ + if ( $ENV{CATALYST_SERVER} ) { + skip 'Using remote server', 2; + } + require TestApp::RequestBaseBug; TestApp->request_class('TestApp::RequestBaseBug'); ok( my $response = request('http://localhost/engine/request/uri'), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); TestApp->request_class('Catalyst::Request'); } -