use inlined module hiding in tests
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_uri_with.t
index c8a3ef0..1e13a9b 100644 (file)
@@ -1,69 +1,86 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More;
 use URI;
+use URI::QueryParam;
+use Catalyst::Log;
 
 use_ok('Catalyst::Request');
 
+sub cmp_uri {
+    my ($got, $exp_txt, $comment) = @_;
+    $comment ||= '';
+    my $exp = URI->new($exp_txt);
+    foreach my $thing (qw/ scheme host path /) {
+        is $exp->$thing, $got->$thing, "$comment: $thing";
+    }
+    is_deeply $got->query_form_hash, $exp->query_form_hash, "$comment: query";
+}
+
 my $request = Catalyst::Request->new( {
+                _log => Catalyst::Log->new,
                 uri => URI->new('http://127.0.0.1/foo/bar/baz')
               } );
 
-is(
+cmp_uri(
     $request->uri_with({}),
     'http://127.0.0.1/foo/bar/baz',
     'URI for absolute path'
 );
 
-is(
+cmp_uri(
     $request->uri_with({ foo => 'bar' }),
     'http://127.0.0.1/foo/bar/baz?foo=bar',
     'URI adds param'
 );
 
 my $request2 = Catalyst::Request->new( {
+                _log => Catalyst::Log->new,
                 uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
               } );
-is(
+
+cmp_uri(
     $request2->uri_with({}),
     'http://127.0.0.1/foo/bar/baz?bar=gorch',
     'URI retains param'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ me => 'awesome' }),
     'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
     'URI retains param and adds new'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ bar => undef }),
     'http://127.0.0.1/foo/bar/baz',
     'URI loses param when explicitly undef'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ bar => 'snort' }),
     'http://127.0.0.1/foo/bar/baz?bar=snort',
     'URI changes param'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ bar => [ 'snort', 'ewok' ] }),
     'http://127.0.0.1/foo/bar/baz?bar=snort&bar=ewok',
     'overwrite mode URI appends arrayref param'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ bar => 'snort' }, { mode => 'append' }),
     'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort',
     'append mode URI appends param'
 );
 
-is(
+cmp_uri(
     $request2->uri_with({ bar => [ 'snort', 'ewok' ] }, { mode => 'append' }),
     'http://127.0.0.1/foo/bar/baz?bar=gorch&bar=snort&bar=ewok',
     'append mode URI appends arrayref param'
 );
 
+done_testing;
+