Added ChildOf tests for args passed to actions
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Action / ChildOf.pm
CommitLineData
141459fa 1package TestApp::Controller::Action::ChildOf;
2
3use strict;
4use warnings;
5
6use base qw/Catalyst::Controller/;
7
8sub begin :Private { }
9
d416846e 10#
11# Simple parent/child action test
12#
922c58d6 13sub foo :PathPart('childof/foo') :Captures(1) :ChildOf('/') { }
922c58d6 14sub endpoint :PathPart('end') :ChildOf('/action/childof/foo') :Args(1) { }
d416846e 15
16#
17# Parent/child test with two args each
18#
19sub foo2 :PathPart('childof/foo2') :Captures(2) :ChildOf('/') { }
922c58d6 20sub endpoint2 :PathPart('end2') :ChildOf('/action/childof/foo2') :Args(2) { }
141459fa 21
d416846e 22#
23# Relative specification of parent action
24#
25sub bar :PathPart('childof/bar') :ChildOf('/') { }
141459fa 26sub finale :ChildOf('bar') :Args { }
27
d416846e 28#
29# three chain with concurrent endpoints
30#
922c58d6 31sub one :PathPart('childof/one') :ChildOf('/') :Captures(1) { }
32sub two :PathPart('two') :ChildOf('/action/childof/one') :Captures(2) { }
922c58d6 33sub three_end :PathPart('three') :ChildOf('two') :Args(3) { }
34sub one_end :PathPart('childof/one') :ChildOf('/') :Args(1) { }
35sub two_end :PathPart('two') :ChildOf('one') :Args(2) { }
36
d416846e 37#
38# Dispatch on number of arguments
39#
922c58d6 40sub multi1 :PathPart('childof/multi') :ChildOf('/') :Args(1) { }
41sub multi2 :PathPart('childof/multi') :ChildOf('/') :Args(2) { }
42
d416846e 43#
44# Roots in an action defined in a higher controller
45#
46sub higher_root :PathPart('bar') :ChildOf('/action/childof/foo/higher_root') :Args(1) { }
47
48#
49# Controller -> subcontroller -> controller
50#
51sub pcp1 :PathPart('childof/pcp1') :ChildOf('/') :Captures(1) { }
52sub pcp3 :PathPart :ChildOf('/action/childof/foo/pcp2') :Args(1) { }
53
54#
55# Dispatch on capture number
56#
57sub multi_cap1 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(1) { }
58sub multi_cap2 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(2) { }
59sub multi_cap_end1 :PathPart('baz') :ChildOf('multi_cap1') :Args(0) { }
60sub multi_cap_end2 :PathPart('baz') :ChildOf('multi_cap2') :Args(0) { }
61
62#
63# Priority: Slurpy args vs. chained actions
64#
65sub priority_a1 :PathPart('childof/priority_a') :ChildOf('/') :Args { }
66sub priority_a2 :PathPart('childof/priority_a') :ChildOf('/') :Captures(1) { }
67sub priority_a2_end :PathPart('end') :ChildOf('priority_a2') :Args(1) { }
68
69#
70# Priority: Fixed args vs. chained actions
71#
72sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { }
73sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { }
74sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { }
75
141459fa 76sub end :Private {
77 my ($self, $c) = @_;
78 my $out = join('; ', map { join(', ', @$_) }
79 ($c->req->captures, $c->req->args));
80 $c->res->body($out);
81}
82
831;