use Test::More;
-plan tests => 12;
+plan tests => 17;
use_ok('TestApp');
ok(!defined($dispatcher->uri_for_action($regex_action)),
"Regex action without captures returns undef");
+ok(!defined($dispatcher->uri_for_action($regex_action, [ 1, 2, 3 ])),
+ "Regex action with too many captures returns undef");
+
is($dispatcher->uri_for_action($regex_action, [ 'foo', 123 ]),
"/action/regexp/foo/123",
"Regex action interpolates captures correctly");
"/action/index",
"index action returns correct path");
+my $childof_action = $dispatcher->get_action_by_path(
+ '/action/childof/endpoint',
+ );
+
+ok(!defined($dispatcher->uri_for_action($childof_action)),
+ "ChildOf action without captures returns undef");
+
+ok(!defined($dispatcher->uri_for_action($childof_action, [ 1, 2 ])),
+ "ChildOf action with too many captures returns undef");
+
+is($dispatcher->uri_for_action($childof_action, [ 1 ]),
+ "/childof/foo/1/end",
+ "ChildOf action with correct captures returns correct path");
+
my $request = Catalyst::Request->new( {
base => URI->new('http://127.0.0.1/foo')
} );
is($context->uri_for($regex_action, [ 'foo', 123 ], qw/bar baz/, { q => 1 }),
"http://127.0.0.1/foo/action/regexp/foo/123/bar/baz?q=1",
"uri_for correct for regex with captures, args and query");
+
+is($context->uri_for($childof_action, [ 1 ], 2, { q => 1 }),
+ "http://127.0.0.1/foo/childof/foo/1/end/2?q=1",
+ "uri_for correct for childof with captures, args and query");