Commit | Line | Data |
3c9e6294 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More tests => 7; |
5 | use URI; |
6 | |
7 | use_ok('Catalyst::Request'); |
8 | |
9 | my $request = Catalyst::Request->new( { |
10 | uri => URI->new('http://127.0.0.1/foo/bar/baz') |
11 | } ); |
12 | |
13 | is( |
14 | $request->uri_with({}), |
15 | 'http://127.0.0.1/foo/bar/baz', |
16 | 'URI for absolute path' |
17 | ); |
18 | |
19 | is( |
20 | $request->uri_with({ foo => 'bar' }), |
21 | 'http://127.0.0.1/foo/bar/baz?foo=bar', |
22 | 'URI adds param' |
23 | ); |
24 | |
25 | my $request2 = Catalyst::Request->new( { |
26 | uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch') |
27 | } ); |
28 | is( |
29 | $request2->uri_with({}), |
30 | 'http://127.0.0.1/foo/bar/baz?bar=gorch', |
31 | 'URI retains param' |
32 | ); |
33 | |
34 | is( |
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' |
38 | ); |
39 | |
40 | is( |
41 | $request2->uri_with({ bar => undef }), |
42 | 'http://127.0.0.1/foo/bar/baz', |
43 | 'URI loses param when explicitly undef' |
44 | ); |
45 | |
46 | is( |
47 | $request2->uri_with({ bar => 'snort' }), |
48 | 'http://127.0.0.1/foo/bar/baz?bar=snort', |
49 | 'URI changes param' |
50 | ); |