From: Cory G Watson Date: Tue, 14 Apr 2009 14:25:22 +0000 (+0000) Subject: Add uri_with tests (nothing was broken, but I had some problems locally and X-Git-Tag: 5.80001~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=3c9e62941f58bc6d8d22c6b8a2a2f7bf5b1c5ab0 Add uri_with tests (nothing was broken, but I had some problems locally and test coverage is always good) --- diff --git a/Changes b/Changes index e82bf60..481b0cb 100644 --- a/Changes +++ b/Changes @@ -63,6 +63,7 @@ cases (t0m) - Tests for this (t0m) - Use of deprecated Catalyst::Base now warns. (t0m) + - Add uri_with tests (gphat) 5.8000_06 2009-02-04 21:00 - Disallow writing to config after setup (rafl) diff --git a/t/unit_core_uri_with.t b/t/unit_core_uri_with.t new file mode 100644 index 0000000..a35f758 --- /dev/null +++ b/t/unit_core_uri_with.t @@ -0,0 +1,50 @@ +use strict; +use warnings; + +use Test::More tests => 7; +use URI; + +use_ok('Catalyst::Request'); + +my $request = Catalyst::Request->new( { + uri => URI->new('http://127.0.0.1/foo/bar/baz') + } ); + +is( + $request->uri_with({}), + 'http://127.0.0.1/foo/bar/baz', + 'URI for absolute path' +); + +is( + $request->uri_with({ foo => 'bar' }), + 'http://127.0.0.1/foo/bar/baz?foo=bar', + 'URI adds param' +); + +my $request2 = Catalyst::Request->new( { + uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch') + } ); +is( + $request2->uri_with({}), + 'http://127.0.0.1/foo/bar/baz?bar=gorch', + 'URI retains param' +); + +is( + $request2->uri_with({ me => 'awesome' }), + 'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome', + 'URI retains param and adds new' +); + +is( + $request2->uri_with({ bar => undef }), + 'http://127.0.0.1/foo/bar/baz', + 'URI loses param when explicitly undef' +); + +is( + $request2->uri_with({ bar => 'snort' }), + 'http://127.0.0.1/foo/bar/baz?bar=snort', + 'URI changes param' +);