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