9 use_ok('Catalyst::Request');
12 my ($got, $exp_txt, $comment) = @_;
14 my $exp = URI->new($exp_txt);
15 foreach my $thing (qw/ scheme host path /) {
16 is $exp->$thing, $got->$thing, "$comment: $thing";
18 is_deeply $got->query_form_hash, $exp->query_form_hash, "$comment: query";
21 my $request = Catalyst::Request->new( {
22 _log => Catalyst::Log->new,
23 uri => URI->new('http://127.0.0.1/foo/bar/baz')
27 $request->uri_with({}),
28 'http://127.0.0.1/foo/bar/baz',
29 'URI for absolute path'
33 $request->uri_with({ foo => 'bar' }),
34 'http://127.0.0.1/foo/bar/baz?foo=bar',
38 my $request2 = Catalyst::Request->new( {
39 _log => Catalyst::Log->new,
40 uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
44 $request2->uri_with({}),
45 'http://127.0.0.1/foo/bar/baz?bar=gorch',
50 $request2->uri_with({ me => 'awesome' }),
51 'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
52 'URI retains param and adds new'
56 $request2->uri_with({ bar => undef }),
57 'http://127.0.0.1/foo/bar/baz',
58 'URI loses param when explicitly undef'
62 $request2->uri_with({ bar => 'snort' }),
63 'http://127.0.0.1/foo/bar/baz?bar=snort',
68 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }),
69 'http://127.0.0.1/foo/bar/baz?bar=snort&bar=ewok',
70 'overwrite mode URI appends arrayref param'
74 $request2->uri_with({ bar => 'snort' }, { mode => 'append' }),
75 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort',
76 'append mode URI appends param'
80 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }, { mode => 'append' }),
81 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort&bar=ewok',
82 'append mode URI appends arrayref param'