Make URI query param tests simpler and more robust
Dagfinn Ilmari Mannsåker [Wed, 5 Dec 2012 12:07:02 +0000 (12:07 +0000)]
t/aggregate/live_component_controller_action_chained.t
t/aggregate/unit_core_uri_with.t

index b4907f7..d6fcfed 100644 (file)
@@ -11,6 +11,8 @@ our $iters;
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
 use Test::More;
+use URI;
+use URI::QueryParam;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -1115,9 +1117,7 @@ sub run_tests {
         # where the app is based (live tests etc)
         is $got->path, $exp->path, "uri $path can round trip through uri_for (path)"
             or diag("Expected $path, got $content");
-        my %got_q = map { split /=/ } split /\&/, ($got->query||'');
-        my %exp_q = map { split /=/ } split /\&/, ($exp->query||'');
-        is_deeply \%got_q, \%exp_q, "uri $path can round trip through uri_for (query)"
+        is_deeply $got->query_form_hash, $exp->query_form_hash, "uri $path can round trip through uri_for (query)"
             or diag("Expected $path, got $content");
     }
 
index 0af788f..1e13a9b 100644 (file)
@@ -3,6 +3,7 @@ use warnings;
 
 use Test::More;
 use URI;
+use URI::QueryParam;
 use Catalyst::Log;
 
 use_ok('Catalyst::Request');
@@ -14,9 +15,7 @@ sub cmp_uri {
     foreach my $thing (qw/ scheme host path /) {
         is $exp->$thing, $got->$thing, "$comment: $thing";
     }
-    my %got_q = map { split /=/ } split /\&/, ($got->query||'');
-    my %exp_q = map { split /=/ } split /\&/, ($exp->query||'');
-    is_deeply \%got_q, \%exp_q, "$comment: query";
+    is_deeply $got->query_form_hash, $exp->query_form_hash, "$comment: query";
 }
 
 my $request = Catalyst::Request->new( {