[Catalyst-commits] r9698 - in Catalyst-Runtime/5.80/trunk: . t

gphat at dev.catalyst.perl.org gphat at dev.catalyst.perl.org
Tue Apr 14 14:25:22 GMT 2009


Author: gphat
Date: 2009-04-14 15:25:22 +0100 (Tue, 14 Apr 2009)
New Revision: 9698

Added:
   Catalyst-Runtime/5.80/trunk/t/unit_core_uri_with.t
Modified:
   Catalyst-Runtime/5.80/trunk/Changes
Log:
Add uri_with tests (nothing was broken, but I had some problems locally and
test coverage is always good)


Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2009-04-14 11:35:24 UTC (rev 9697)
+++ Catalyst-Runtime/5.80/trunk/Changes	2009-04-14 14:25:22 UTC (rev 9698)
@@ -63,6 +63,7 @@
           cases (t0m)
           - Tests for this (t0m)
         - Use of deprecated Catalyst::Base now warns. (t0m)
+        - Add uri_with tests (gphat)
 
 5.8000_06 2009-02-04 21:00
         - Disallow writing to config after setup (rafl)

Added: Catalyst-Runtime/5.80/trunk/t/unit_core_uri_with.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_uri_with.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_uri_with.t	2009-04-14 14:25:22 UTC (rev 9698)
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+use URI;
+
+use_ok('Catalyst::Request');
+
+my $request = Catalyst::Request->new( {
+                uri => URI->new('http://127.0.0.1/foo/bar/baz')
+              } );
+
+is(
+    $request->uri_with({}),
+    'http://127.0.0.1/foo/bar/baz',
+    'URI for absolute path'
+);
+
+is(
+    $request->uri_with({ foo => 'bar' }),
+    'http://127.0.0.1/foo/bar/baz?foo=bar',
+    'URI adds param'
+);
+
+my $request2 = Catalyst::Request->new( {
+                uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
+              } );
+is(
+    $request2->uri_with({}),
+    'http://127.0.0.1/foo/bar/baz?bar=gorch',
+    'URI retains param'
+);
+
+is(
+    $request2->uri_with({ me => 'awesome' }),
+    'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
+    'URI retains param and adds new'
+);
+
+is(
+    $request2->uri_with({ bar => undef }),
+    'http://127.0.0.1/foo/bar/baz',
+    'URI loses param when explicitly undef'
+);
+
+is(
+    $request2->uri_with({ bar => 'snort' }),
+    'http://127.0.0.1/foo/bar/baz?bar=snort',
+    'URI changes param'
+);




More information about the Catalyst-commits mailing list