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)
--- /dev/null
+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'
+);