4 use Test::More tests => 10;
7 use_ok('Catalyst::Request');
9 my $request = Catalyst::Request->new( {
10 uri => URI->new('http://127.0.0.1/foo/bar/baz')
14 $request->uri_with({}),
15 'http://127.0.0.1/foo/bar/baz',
16 'URI for absolute path'
20 $request->uri_with({ foo => 'bar' }),
21 'http://127.0.0.1/foo/bar/baz?foo=bar',
25 my $request2 = Catalyst::Request->new( {
26 uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
29 $request2->uri_with({}),
30 'http://127.0.0.1/foo/bar/baz?bar=gorch',
35 $request2->uri_with({ me => 'awesome' }),
36 'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
37 'URI retains param and adds new'
41 $request2->uri_with({ bar => undef }),
42 'http://127.0.0.1/foo/bar/baz',
43 'URI loses param when explicitly undef'
47 $request2->uri_with({ bar => 'snort' }),
48 'http://127.0.0.1/foo/bar/baz?bar=snort',
53 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }),
54 'http://127.0.0.1/foo/bar/baz?bar=snort&bar=ewok',
55 'overwrite mode URI appends arrayref param'
59 $request2->uri_with({ bar => 'snort' }, { mode => 'append' }),
60 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort',
61 'append mode URI appends param'
65 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }, { mode => 'append' }),
66 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort&bar=ewok',
67 'append mode URI appends arrayref param'