added $c->req->uri_with helper + tests
[catagits/Catalyst-Runtime.git] / t / live_engine_request_uri.t
index 5af97f9..3bfaec4 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use FindBin;\r
 use lib "$FindBin::Bin/lib";\r
 \r
-use Test::More tests => 23;\r
+use Test::More tests => 35;\r
 use Catalyst::Test 'TestApp';\r
 use Catalyst::Request;\r
 \r
@@ -59,3 +59,27 @@ my $creq;
     is( $creq->{uri}->query, 'text=Catalyst%20Rocks', 'Query string ok' );\r
     is( $creq->{parameters}->{text}, 'Catalyst Rocks', 'Unescaped param ok' );\r
 }\r
+\r
+# test that uri_with adds params\r
+{\r
+    ok( my $response = request('http://localhost/engine/request/uri/uri_with'), 'Request' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    ok( !defined $response->header( 'X-Catalyst-Param-a' ), 'param "a" ok' );\r
+    is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );\r
+}\r
+\r
+# test that uri_with adds params (and preserves)\r
+{\r
+    ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1'), 'Request' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );\r
+    is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );\r
+}\r
+\r
+# test that uri_with replaces params (and preserves)\r
+{\r
+    ok( my $response = request('http://localhost/engine/request/uri/uri_with?a=1&b=2'), 'Request' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->header( 'X-Catalyst-Param-a' ), '1', 'param "a" ok' );\r
+    is( $response->header( 'X-Catalyst-Param-b' ), '1', 'param "b" ok' );\r
+}\r