Corrected 'snippets' -> 'captures' in Chained Intro
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Action / Chained.pm
CommitLineData
5882c86e 1package TestApp::Controller::Action::Chained;
2
3use strict;
4use warnings;
5
6use base qw/Catalyst::Controller/;
7
8sub begin :Private { }
9
10#
11# TODO
0e853a7f 12# :Chained('') means what?
5882c86e 13#
14
15#
16# Simple parent/child action test
17#
18sub foo :PathPart('chained/foo') :Captures(1) :Chained('/') { }
19sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
20
21#
22# Parent/child test with two args each
23#
24sub foo2 :PathPart('chained/foo2') :Captures(2) :Chained('/') { }
25sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
26
27#
28# Relative specification of parent action
29#
30sub bar :PathPart('chained/bar') :Chained('/') :Captures(0) { }
31sub finale :PathPart('') :Chained('bar') :Args { }
32
33#
34# three chain with concurrent endpoints
35#
36sub one :PathPart('chained/one') :Chained('/') :Captures(1) { }
37sub two :PathPart('two') :Chained('/action/chained/one') :Captures(2) { }
38sub three_end :PathPart('three') :Chained('two') :Args(3) { }
39sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
40sub two_end :PathPart('two') :Chained('one') :Args(2) { }
41
42#
43# Dispatch on number of arguments
44#
45sub multi1 :PathPart('chained/multi') :Chained('/') :Args(1) { }
46sub multi2 :PathPart('chained/multi') :Chained('/') :Args(2) { }
47
48#
49# Roots in an action defined in a higher controller
50#
51sub higher_root :PathPart('bar') :Chained('/action/chained/foo/higher_root') :Args(1) { }
52
53#
54# Controller -> subcontroller -> controller
55#
56sub pcp1 :PathPart('chained/pcp1') :Chained('/') :Captures(1) { }
57sub pcp3 :Chained('/action/chained/foo/pcp2') :Args(1) { }
58
59#
60# Dispatch on capture number
61#
62sub multi_cap1 :PathPart('chained/multi_cap') :Chained('/') :Captures(1) { }
63sub multi_cap2 :PathPart('chained/multi_cap') :Chained('/') :Captures(2) { }
64sub multi_cap_end1 :PathPart('baz') :Chained('multi_cap1') :Args(0) { }
65sub multi_cap_end2 :PathPart('baz') :Chained('multi_cap2') :Args(0) { }
66
67#
68# Priority: Slurpy args vs. chained actions
69#
70sub priority_a1 :PathPart('chained/priority_a') :Chained('/') :Args { }
71sub priority_a2 :PathPart('chained/priority_a') :Chained('/') :Captures(1) { }
72sub priority_a2_end :PathPart('end') :Chained('priority_a2') :Args(1) { }
73
74#
75# Priority: Fixed args vs. chained actions
76#
77sub priority_b1 :PathPart('chained/priority_b') :Chained('/') :Args(3) { }
78sub priority_b2 :PathPart('chained/priority_b') :Chained('/') :Captures(1) { }
79sub priority_b2_end :PathPart('end') :Chained('priority_b2') :Args(1) { }
80
81#
82# Optional specification of :Args in endpoint
83#
84sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
85
86#
87# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
88#
89sub opt_pp_start :Chained('/') :PathPart('chained/optpp') :Captures(1) { }
90sub opt_pathpart :Chained('opt_pp_start') :Args(1) { }
91
92#
93# Optional Args *and* PathPart -> /chained/optall/*/oa/...
94#
95sub opt_all_start :Chained('/') :PathPart('chained/optall') :Captures(1) { }
96sub oa :Chained('opt_all_start') { }
97
0e853a7f 98#
99# :Chained is the same as :Chained('/')
100#
101sub rootdef :Chained :PathPart('chained/rootdef') :Args(1) { }
102
103#
104# the ParentChain controller chains to this action by
105# specifying :Chained('.')
106#
107sub parentchain :Chained('/') :PathPart('chained/parentchain') :Captures(1) { }
108
5882c86e 109sub end :Private {
110 my ($self, $c) = @_;
111 my $out = join('; ', map { join(', ', @$_) }
112 ($c->req->captures, $c->req->args));
113 $c->res->body($out);
114}
115
1161;