From: Tomas Doran Date: Tue, 4 Dec 2012 21:09:16 +0000 (+0000) Subject: Fix for v5.17.5-518-g7dc8663 X-Git-Tag: 5.90019~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1e8c91ac049beb99fe82c74269fda1436b343d90 Fix for v5.17.5-518-g7dc8663 --- diff --git a/t/aggregate/unit_core_uri_with.t b/t/aggregate/unit_core_uri_with.t index 5e86318..0af788f 100644 --- a/t/aggregate/unit_core_uri_with.t +++ b/t/aggregate/unit_core_uri_with.t @@ -7,18 +7,30 @@ use Catalyst::Log; use_ok('Catalyst::Request'); +sub cmp_uri { + my ($got, $exp_txt, $comment) = @_; + $comment ||= ''; + my $exp = URI->new($exp_txt); + foreach my $thing (qw/ scheme host path /) { + is $exp->$thing, $got->$thing, "$comment: $thing"; + } + my %got_q = map { split /=/ } split /\&/, ($got->query||''); + my %exp_q = map { split /=/ } split /\&/, ($exp->query||''); + is_deeply \%got_q, \%exp_q, "$comment: query"; +} + my $request = Catalyst::Request->new( { _log => Catalyst::Log->new, uri => URI->new('http://127.0.0.1/foo/bar/baz') } ); -is( +cmp_uri( $request->uri_with({}), 'http://127.0.0.1/foo/bar/baz', 'URI for absolute path' ); -is( +cmp_uri( $request->uri_with({ foo => 'bar' }), 'http://127.0.0.1/foo/bar/baz?foo=bar', 'URI adds param' @@ -28,43 +40,44 @@ my $request2 = Catalyst::Request->new( { _log => Catalyst::Log->new, uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch') } ); -is( + +cmp_uri( $request2->uri_with({}), 'http://127.0.0.1/foo/bar/baz?bar=gorch', 'URI retains param' ); -is( +cmp_uri( $request2->uri_with({ me => 'awesome' }), 'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome', 'URI retains param and adds new' ); -is( +cmp_uri( $request2->uri_with({ bar => undef }), 'http://127.0.0.1/foo/bar/baz', 'URI loses param when explicitly undef' ); -is( +cmp_uri( $request2->uri_with({ bar => 'snort' }), 'http://127.0.0.1/foo/bar/baz?bar=snort', 'URI changes param' ); -is( +cmp_uri( $request2->uri_with({ bar => [ 'snort', 'ewok' ] }), 'http://127.0.0.1/foo/bar/baz?bar=snort&bar=ewok', 'overwrite mode URI appends arrayref param' ); -is( +cmp_uri( $request2->uri_with({ bar => 'snort' }, { mode => 'append' }), 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort', 'append mode URI appends param' ); -is( +cmp_uri( $request2->uri_with({ bar => [ 'snort', 'ewok' ] }, { mode => 'append' }), 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort&bar=ewok', 'append mode URI appends arrayref param'