8 use_ok('Catalyst::Request');
11 my ($got, $exp_txt, $comment) = @_;
13 my $exp = URI->new($exp_txt);
14 foreach my $thing (qw/ scheme host path /) {
15 is $exp->$thing, $got->$thing, "$comment: $thing";
17 my %got_q = map { split /=/ } split /\&/, ($got->query||'');
18 my %exp_q = map { split /=/ } split /\&/, ($exp->query||'');
19 is_deeply \%got_q, \%exp_q, "$comment: query";
22 my $request = Catalyst::Request->new( {
23 _log => Catalyst::Log->new,
24 uri => URI->new('http://127.0.0.1/foo/bar/baz')
28 $request->uri_with({}),
29 'http://127.0.0.1/foo/bar/baz',
30 'URI for absolute path'
34 $request->uri_with({ foo => 'bar' }),
35 'http://127.0.0.1/foo/bar/baz?foo=bar',
39 my $request2 = Catalyst::Request->new( {
40 _log => Catalyst::Log->new,
41 uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
45 $request2->uri_with({}),
46 'http://127.0.0.1/foo/bar/baz?bar=gorch',
51 $request2->uri_with({ me => 'awesome' }),
52 'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
53 'URI retains param and adds new'
57 $request2->uri_with({ bar => undef }),
58 'http://127.0.0.1/foo/bar/baz',
59 'URI loses param when explicitly undef'
63 $request2->uri_with({ bar => 'snort' }),
64 'http://127.0.0.1/foo/bar/baz?bar=snort',
69 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }),
70 'http://127.0.0.1/foo/bar/baz?bar=snort&bar=ewok',
71 'overwrite mode URI appends arrayref param'
75 $request2->uri_with({ bar => 'snort' }, { mode => 'append' }),
76 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort',
77 'append mode URI appends param'
81 $request2->uri_with({ bar => [ 'snort', 'ewok' ] }, { mode => 'append' }),
82 'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort&bar=ewok',
83 'append mode URI appends arrayref param'